Sha256: 1b2e4fe9a59e4360ea74802168f1e19c4e5c93684ea047dce472c62261d70213
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' require 'wlang/mustang' module WLang describe Mustang do describe "The Highlighter example" do class Highlighter < WLang::Dialect def highlight(buf, fn) var_name = render(fn) var_value = evaluate(var_name) buf << var_value.to_s.upcase end tag '$', :highlight end it 'works as announced' do expected = "Hello YOU & THE WORLD!" got = Highlighter.render "Hello ${who}!", :who => "you & the world" got.should eq(expected) end end # Highlighter example describe "the HighLevel example" do class HighLevel < WLang::Dialect def join(buf, expr, main, between) evaluate(expr).each_with_index do |val,i| buf << render(between, val) unless i==0 buf << render(main, val).strip end end def print(buf, fn) buf << evaluate(fn).to_s end tag '*', :join tag '$', :print end it 'works as announced' do expected = "Hello you and wlang and world !" template = 'Hello *{ ${collection} }{ ${self} }{ and } !' context = {:collection => 'whos', :whos => [ "you", "wlang", "world" ] } got = HighLevel.render template, context got.should eq(expected) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wlang-2.0.0.beta | spec/integration/test_readme.rb |