Class: Txbr::ContentTag

Inherits:
Object
  • Object
show all
Defined in:
lib/txbr/content_tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tagObject (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

#templateObject (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

Returns:

  • (Boolean)


32
33
34
# File 'lib/txbr/content_tag.rb', line 32

def contains_translations?
  .project_slug && .resource_slug && .prefix
end

#metadataObject



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_manifestObject



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