Class: Occams::Content::Tag
- Inherits:
-
Object
- Object
- Occams::Content::Tag
- Defined in:
- lib/occams/content/tag.rb
Direct Known Subclasses
Block, Occams::Content::Tags::Asset, Occams::Content::Tags::Audio, Occams::Content::Tags::Breadcrumbs, Occams::Content::Tags::Children, Occams::Content::Tags::FileLink, Occams::Content::Tags::Fragment, Occams::Content::Tags::Helper, Occams::Content::Tags::Image, Occams::Content::Tags::PageFileLink, Occams::Content::Tags::Partial, Occams::Content::Tags::Siblings, Occams::Content::Tags::Snippet, Occams::Content::Tags::Template
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#allow_erb? ⇒ Boolean
Making sure we don’t leak erb from tags by accident.
- #content ⇒ String
-
#initialize(context:, params: [], source: nil) ⇒ Tag
constructor
A new instance of Tag.
-
#nodes ⇒ Array<String, Occams::Content::Tag>
Normally it’s a (String).
- #render ⇒ String
Constructor Details
#initialize(context:, params: [], source: nil) ⇒ Tag
Returns a new instance of Tag.
18 19 20 21 22 |
# File 'lib/occams/content/tag.rb', line 18 def initialize(context:, params: [], source: nil) @context = context @params = params @source = source end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/occams/content/tag.rb', line 7 def context @context end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/occams/content/tag.rb', line 10 def params @params end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
13 14 15 |
# File 'lib/occams/content/tag.rb', line 13 def source @source end |
Instance Method Details
#allow_erb? ⇒ Boolean
Making sure we don’t leak erb from tags by accident. Tag classes can override this, like partials/helpers tags.
26 27 28 |
# File 'lib/occams/content/tag.rb', line 26 def allow_erb? Occams.config.allow_erb end |
#content ⇒ String
40 41 42 |
# File 'lib/occams/content/tag.rb', line 40 def content raise Error, 'This is a base class. It holds no content' end |
#nodes ⇒ Array<String, Occams::Content::Tag>
Normally it’s a (String). However, if tag content has tags, we need to expand them and that produces potentially more stuff.
33 34 35 36 37 |
# File 'lib/occams/content/tag.rb', line 33 def nodes template = Occams::Content::Renderer.new(@context) tokens = template.tokenize(content) template.nodes(tokens) end |
#render ⇒ String
45 46 47 |
# File 'lib/occams/content/tag.rb', line 45 def render content end |