Sha256: b6df13ea0d5ecdb2349a7ca026801ba70b7d3e91ed4fa472bcc44b11b8dc9e94
Contents?: true
Size: 1.73 KB
Versions: 9
Compression:
Stored size: 1.73 KB
Contents
module Cutaneous class Compiler class Expression def initialize(expression) @expression = expression end def to_script %{__buf << __decode_params((} << @expression << %{)) ; } end def affect(builder) builder.push(self) end end class EscapedExpression < Expression def to_script %{__buf << escape(__decode_params((} << @expression << %{))) ; } end end class Statement < Expression def to_script "" << @expression << " ; " end end class Text < Expression BEGINNING_WHITESPACE ||= /\A(\s*?[\r\n]+)/ def initialize(expression, strip_whitespace = false) @whitespace = "" if strip_whitespace && expression =~ BEGINNING_WHITESPACE @whitespace = $1 expression.slice!(0, @whitespace.length) end super(expression) end def to_script %(__buf << %Q`) << @expression << %(` ; ) << @whitespace << ";" end end class Comment < Expression # Need to make sure that the line positions are the same def to_script $/ * (@expression.count($/)) end end class Extends def initialize(template_name) @template_name = template_name end def affect(builder) builder.extends(@template_name) end end class BlockStart def initialize(block_name) @block_name = block_name.to_sym end def affect(builder) builder.block_start(@block_name) end end class BlockEnd def affect(builder) builder.block_end end end class BlockSuper def affect(builder) builder.block_super end end end end
Version data entries
9 entries across 9 versions & 1 rubygems