Class: Txbr::ContentTag
- Inherits:
-
Object
- Object
- Txbr::ContentTag
- Defined in:
- lib/txbr/content_tag.rb
Instance Attribute Summary collapse
-
#liquid_tag ⇒ Object
readonly
Returns the value of attribute liquid_tag.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #contains_translations? ⇒ Boolean
-
#initialize(template, liquid_tag) ⇒ ContentTag
constructor
A new instance of ContentTag.
- #metadata ⇒ Object
- #strings_manifest ⇒ Object
Constructor Details
#initialize(template, liquid_tag) ⇒ ContentTag
Returns a new instance of ContentTag.
9 10 11 12 |
# File 'lib/txbr/content_tag.rb', line 9 def initialize(template, liquid_tag) @template = template @liquid_tag = liquid_tag end |
Instance Attribute Details
#liquid_tag ⇒ Object (readonly)
Returns the value of attribute liquid_tag.
7 8 9 |
# File 'lib/txbr/content_tag.rb', line 7 def liquid_tag @liquid_tag end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/txbr/content_tag.rb', line 7 def template @template end |
Instance Method Details
#contains_translations? ⇒ Boolean
32 33 34 |
# File 'lib/txbr/content_tag.rb', line 32 def contains_translations? .project_slug && .resource_slug && .prefix end |
#metadata ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/txbr/content_tag.rb', line 14 def @metadata ||= begin # Render the template to implicitly populate the metadata hash inside # the liquid tag object. We do this because we encourage templates to # set local variables for the project and resource slugs. It's less # error-prone to let Liquid do the template evaluation instead of # grepping through the nodelist looking for assignment statements. template.render liquid_tag. end end |
#strings_manifest ⇒ Object
26 27 28 29 30 |
# File 'lib/txbr/content_tag.rb', line 26 def strings_manifest @strings_manifest ||= StringsManifest.new.tap do |manifest| extract_strings_from(template.root, manifest) end end |