Sha256: 97a8e4c18a40191b5b29f7ed0ac6840cb28827e3d342121713554825201b9964

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

class Musterb::Musterbifier
  def initialize(template)
    @template = template
  end

  def to_erb
    @template.gsub(/\{\{(\{?[^\}]*\}?)\}\}/) do |match|
      match = $1
      case match[0]
      when '#'
        "<% musterb.block '#{match[1..-1]}' do %>"
      when '^'
        "<% musterb.block_unless '#{match[1..-1]}' do %>"
      when "/"
        "<% end %>"
      when '{'
        "<%= musterb['#{match[1..-2]}'] %>"
      else
        "<%== musterb['#{match}'] %>"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
musterb-0.0.1 lib/musterb/musterbifier.rb