Sha256: b02285d85b4f0a908607606c2c90a2fe54a3b50bc15469ca54f89bed43fcd7bc

Contents?: true

Size: 1.2 KB

Versions: 20

Compression:

Stored size: 1.2 KB

Contents

require 'spiderfw/templates/template_blocks'
require 'strscan'

module Spider; module TemplateBlocks
    ExpressionOutputRegexp = /\{?\{\s([^\s].*?)\s\}\}?/
    GettextRegexp = /([snp][snp]?)?_\(([^\)]+)?\)(\s%\s([^\s,]+(?:,\s*\S+\s*)?))?/
    ERBRegexp = /(<%(.+)?%>)/
    
    class Text < Block

        
        def compile(options={})
            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 << #{val[:func]}_('#{escape_text(val[:val])}')"
                    if val[:vars]
                        c += " % [#{vars_to_scene(val[:vars])}]" 
                    end
                    c += "\n"
                when :erb
                    c += val
                end
            end
            return CompiledBlock.new(nil, c)
            
        end
        
        
        
    end
    
    
end; end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
spiderfw-1.0.1 lib/spiderfw/templates/blocks/text.rb
spiderfw-1.0.0 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.39 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.38 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.37 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.35 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.34 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.33 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.32 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.31 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.30 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.29 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.28 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.27 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.26 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.26.pre1 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.25 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.24 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.23 lib/spiderfw/templates/blocks/text.rb
spiderfw-0.6.22 lib/spiderfw/templates/blocks/text.rb