1
0
Fork 0
template_engine_comparison/lib/workbench/wrappers/tagz.rb

34 lines
554 B
Ruby
Raw Normal View History

2013-12-14 20:42:15 +00:00
module Workbench
module Wrappers
class Tagz < Base
def initialize path
2013-12-14 21:06:34 +00:00
require path
if path.end_with?('small.rb')
@tpl = TagzTemplates::Small.new
else
@tpl = TagzTemplates::Big.new
end
2013-12-14 20:42:15 +00:00
end
def render context, args = {}
2013-12-14 21:06:34 +00:00
@tpl.with_args(args).render
2013-12-14 20:42:15 +00:00
end
2013-12-14 21:06:34 +00:00
end
end
end
2013-12-14 20:42:15 +00:00
2013-12-14 21:06:34 +00:00
module TagzTemplates
class Base
include Tagz
2013-12-14 20:42:15 +00:00
2013-12-14 21:06:34 +00:00
def with_args args
args.each do |key, val|
instance_variable_set(:"@#{key}", val)
2013-12-14 20:42:15 +00:00
end
2013-12-14 21:06:34 +00:00
self
2013-12-14 20:42:15 +00:00
end
end
end