Sha256: 037364ceb73204ec69782dcd76bc8c1d3e04b7d7c4b4ae2a7bf181cbce7ebef1

Contents?: true

Size: 503 Bytes

Versions: 3

Compression:

Stored size: 503 Bytes

Contents

module Rcurse
    @helpers = Hash.new

    def self.add_helper helper
        @helpers[helper.name] = helper
    end

    def self.helpers
        @helpers
    end

    def self.render filename
        file_contents = File.read filename
        file_contents.gsub /{{([^ ]+) *(.+)?}}/ do |s|
            name = $1
            args = $2 ? $2.split(" ") : []
            if @helpers[name].is_a? Rcurse::Helper then
                @helpers[name].callback.call(args)
            end
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rcurse-0.2.5 lib/rcurse/engine.rb
rcurse-0.2.0 lib/rcurse/engine.rb
rcurse-0.1.5 lib/rcurse/engine.rb