Class: ComfortableMexicanSofa::Content::Tag
- Inherits:
-
Object
- Object
- ComfortableMexicanSofa::Content::Tag
- Defined in:
- lib/comfortable_mexican_sofa/content/tag.rb
Direct Known Subclasses
Block, Asset, FileLink, Fragment, Helper, PageFileLink, Partial, Snippet, Template
Defined Under Namespace
Modules: Mixins Classes: Asset, Checkbox, Date, Datetime, Error, File, FileLink, Files, Fragment, Helper, Markdown, Number, PageFileLink, Partial, Snippet, Template, Text, TextArea, Wysiwyg
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, ComfortableMexicanSofa::Content::Tag>
Normally it’s a (String).
- #render ⇒ String
Constructor Details
#initialize(context:, params: [], source: nil) ⇒ Tag
Returns a new instance of Tag.
19 20 21 22 23 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 19 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.
8 9 10 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 8 def context @context end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 11 def params @params end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
14 15 16 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 14 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.
27 28 29 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 27 def allow_erb? ComfortableMexicanSofa.config.allow_erb end |
#content ⇒ String
41 42 43 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 41 def content raise Error, "This is a base class. It holds no content" end |
#nodes ⇒ Array<String, ComfortableMexicanSofa::Content::Tag>
Normally it’s a (String). However, if tag content has tags, we need to expand them and that produces potentially more stuff.
34 35 36 37 38 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 34 def nodes template = ComfortableMexicanSofa::Content::Renderer.new(@context) tokens = template.tokenize(content) template.nodes(tokens) end |
#render ⇒ String
46 47 48 |
# File 'lib/comfortable_mexican_sofa/content/tag.rb', line 46 def render content end |