Class: Spider::TemplateBlocks::Text
- Defined in:
- lib/spiderfw/templates/blocks/text.rb
Instance Attribute Summary
Attributes inherited from Block
#allowed_blocks, #doctype, #el, #template
Instance Method Summary collapse
Methods inherited from Block
#compile_content, #compile_text, #escape_text, #get_following, #initialize, #inspect, #parse_content, var_to_scene, #var_to_scene, #vars_to_scene, vars_to_scene
Constructor Details
This class inherits a constructor from Spider::TemplateBlocks::Block
Instance Method Details
#compile(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/spiderfw/templates/blocks/text.rb', line 12 def compile(={}) text = @el.content c = "" Spider::Template.scan_text(text) do |type, val, full| case type when :plain c += "$out << '#{escape_text(val)}'\n" when :escaped_expr c += "$out << '{ #{escape_text(val)} }'\n" when :expr c += "$out << #{vars_to_scene(val)}\n" when :gettext c += "$out << _('#{escape_text(val[0])}')" if val[1] c += " % [#{vars_to_scene(val[1])}]" end c += "\n" when :erb c += val end end return CompiledBlock.new(nil, c) end |