Class: Liquid::Div
- Inherits:
-
DmCore::LiquidBlock
- Object
- DmCore::LiquidBlock
- Liquid::Div
- Defined in:
- lib/dm_cms/liquid/tags/div.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#render(context) ⇒ Object
——————————————————————————.
Class Method Details
.details ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dm_cms/liquid/tags/div.rb', line 19 def self.details { name: self.tag_name, summary: 'HTML div block', category: 'structure', description: <<-END_OF_DESCRIPTION Outputs an HTML 'div' block. You can specify id, class, and style. You can also specify the markdown modifier, such as 'markdown: 0', if you don't wish the contents to be processed by Markdown. ~~~ {% div id: some_id, class: "class1 class2", style: "color: red; background-color: #aaa;" %} ...content {% enddiv %} ~~~ _Note:_ `class` and `style` are specified the same as a normal HTML div END_OF_DESCRIPTION } end |
Instance Method Details
#render(context) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dm_cms/liquid/tags/div.rb', line 5 def render(context) @attributes.reverse_merge! 'class' => '', 'id' => '', 'style' => '', 'markdown' => '' output = super style = "style='#{@attributes["style"]}'" unless @attributes['style'].blank? dclass = "class='#{@attributes["class"]}'" unless @attributes['class'].blank? id = "id='#{@attributes["id"]}'" unless @attributes['id'].blank? markdown = "markdown='#{@attributes["markdown"]}'" unless @attributes['markdown'].blank? out = "<div #{[id, dclass, style, markdown].join(' ')}>" out += output out += "</div>" end |