1
0
Fork 0
This commit is contained in:
Gregory Eremin 2013-12-15 03:42:15 +07:00
parent 9becb386fb
commit 47d5ab67a0
No known key found for this signature in database
GPG Key ID: 5EFA427EEC26E86C
8 changed files with 90 additions and 3 deletions

View File

@ -11,5 +11,8 @@ gem 'mustache'
gem 'markaby' gem 'markaby'
gem 'tenjin' gem 'tenjin'
gem 'handlebars' gem 'handlebars'
# gem 'liquor' gem 'tagz'
# gem 'parkaby', github: 'judofyr/parkaby'
# gem 'liquor' # No docs - no wrapper
# gem 'parkaby', github: 'judofyr/parkaby' # No gemspec
# gem 'laminate' # No gemspec, dead

View File

@ -23,6 +23,7 @@ GEM
slim (2.0.2) slim (2.0.2)
temple (~> 0.6.6) temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1) tilt (>= 1.3.3, < 2.1)
tagz (9.9.2)
temple (0.6.7) temple (0.6.7)
tenjin (0.7.1) tenjin (0.7.1)
therubyracer (0.12.0) therubyracer (0.12.0)
@ -42,5 +43,6 @@ DEPENDENCIES
markaby markaby
mustache mustache
slim slim
tagz
tenjin tenjin
tilt tilt

View File

@ -57,6 +57,10 @@ Workbench::Benchmark.describe_engines(
# class: Workbench::Wrappers::Parkaby, # class: Workbench::Wrappers::Parkaby,
# extension: 'mab' # extension: 'mab'
# }, # },
tagz: {
class: Workbench::Wrappers::Tagz,
extension: 'tagz'
},
) )
templates = {} templates = {}

View File

@ -14,6 +14,7 @@ require 'mustache'
require 'tenjin' require 'tenjin'
require 'handlebars' require 'handlebars'
# require 'parkaby' # require 'parkaby'
require 'tagz'
require 'tilt/erb' require 'tilt/erb'
require 'tilt/erubis' require 'tilt/erubis'
require 'tilt/haml' require 'tilt/haml'
@ -26,3 +27,4 @@ require 'workbench/wrappers/slim'
require 'workbench/wrappers/tenjin' require 'workbench/wrappers/tenjin'
require 'workbench/wrappers/handlebars' require 'workbench/wrappers/handlebars'
require 'workbench/wrappers/parkaby' require 'workbench/wrappers/parkaby'
require 'workbench/wrappers/tagz'

View File

@ -0,0 +1,31 @@
module Workbench
module Wrappers
class Tagz < Base
def initialize path
@tpl = File.read(path)
@context = Context.new
end
def render context, args = {}
@context.with_args(args).instance_eval(tpl)
end
class Context
include ::Tagz
def with_args args
@args = args
self
end
def method_missing method, *args
if @args.key?(method)
@args[method]
else
super
end
end
end
end
end
end

View File

@ -3,7 +3,7 @@ html {
title 'Customers List' title 'Customers List'
} }
body { body {
customers.each do |customer| customers.each{ |customer|
dl { dl {
dt 'Name:' dt 'Name:'
dd customer['name'] dd customer['name']

26
templates/tagz/big.tagz Normal file
View File

@ -0,0 +1,26 @@
html_{
head_{
title_ 'Customers List'
}
body_{
customers.each{ |customer|
dl_{
dt_ 'Name:'
dd_ customer['name']
dt_ 'Age:'
dd_ customer['age']
dt_ 'Address:'
dd_{
[
customer['zip'],
customer['country'],
customer['city'],
customer['address']
].join("\n")
}
dt_ 'Employer:'
dd_ customer['employer']
}
}
}
}

19
templates/tagz/small.tagz Normal file
View File

@ -0,0 +1,19 @@
html_{
head_{
title_ window_title
}
body_{
h1_ "Hello, #{username}!"
p_{
<<-END
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
END
}
}
}