Sha256: ed39c2c142d31cd10a2562d15dac1124e70e354bd0634f4b43978c64864c15df

Contents?: true

Size: 703 Bytes

Versions: 6

Compression:

Stored size: 703 Bytes

Contents

module ExpressTemplates
  module Compiler
    def compile(template_or_src=nil, &block)
      template, src = _normalize(template_or_src)

      expander = Expander.new(template)

      compiled = expander.expand(src, &block).map(&:compile)

      return compiled.join("+").gsub('"+"', '').tap do |s|
        puts("\n"+template.inspect+"\n"+s) if ENV['DEBUG'].eql?('true')
      end
    end

    private
      def _normalize(template_or_src)
        template, src = nil, nil
        if template_or_src.respond_to?(:source)
          template = template_or_src
          src = template_or_src.source
        else
          src = template_or_src
        end
        return template, src
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
express_templates-0.2.7 lib/express_templates/compiler.rb
express_templates-0.2.6 lib/express_templates/compiler.rb
express_templates-0.2.5 lib/express_templates/compiler.rb
express_templates-0.2.4 lib/express_templates/compiler.rb
express_templates-0.2.3 lib/express_templates/compiler.rb
express_templates-0.2.2 lib/express_templates/compiler.rb