diff --git a/Gemfile b/Gemfile index be26c5a..aefc026 100644 --- a/Gemfile +++ b/Gemfile @@ -11,5 +11,8 @@ gem 'mustache' gem 'markaby' gem 'tenjin' gem 'handlebars' -# gem 'liquor' -# gem 'parkaby', github: 'judofyr/parkaby' +gem 'tagz' + +# gem 'liquor' # No docs - no wrapper +# gem 'parkaby', github: 'judofyr/parkaby' # No gemspec +# gem 'laminate' # No gemspec, dead diff --git a/Gemfile.lock b/Gemfile.lock index 8c0774c..04211e3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,6 +23,7 @@ GEM slim (2.0.2) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) + tagz (9.9.2) temple (0.6.7) tenjin (0.7.1) therubyracer (0.12.0) @@ -42,5 +43,6 @@ DEPENDENCIES markaby mustache slim + tagz tenjin tilt diff --git a/benchmark.rb b/benchmark.rb index a994f90..0ddda83 100755 --- a/benchmark.rb +++ b/benchmark.rb @@ -57,6 +57,10 @@ Workbench::Benchmark.describe_engines( # class: Workbench::Wrappers::Parkaby, # extension: 'mab' # }, + tagz: { + class: Workbench::Wrappers::Tagz, + extension: 'tagz' + }, ) templates = {} diff --git a/lib/workbench.rb b/lib/workbench.rb index 6fa9099..a902edc 100644 --- a/lib/workbench.rb +++ b/lib/workbench.rb @@ -14,6 +14,7 @@ require 'mustache' require 'tenjin' require 'handlebars' # require 'parkaby' +require 'tagz' require 'tilt/erb' require 'tilt/erubis' require 'tilt/haml' @@ -26,3 +27,4 @@ require 'workbench/wrappers/slim' require 'workbench/wrappers/tenjin' require 'workbench/wrappers/handlebars' require 'workbench/wrappers/parkaby' +require 'workbench/wrappers/tagz' diff --git a/lib/workbench/wrappers/tagz.rb b/lib/workbench/wrappers/tagz.rb new file mode 100644 index 0000000..f4c4599 --- /dev/null +++ b/lib/workbench/wrappers/tagz.rb @@ -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 diff --git a/templates/markaby/big.mab b/templates/markaby/big.mab index f1cd297..c7e2e32 100644 --- a/templates/markaby/big.mab +++ b/templates/markaby/big.mab @@ -3,7 +3,7 @@ html { title 'Customers List' } body { - customers.each do |customer| + customers.each{ |customer| dl { dt 'Name:' dd customer['name'] diff --git a/templates/tagz/big.tagz b/templates/tagz/big.tagz new file mode 100644 index 0000000..8662d26 --- /dev/null +++ b/templates/tagz/big.tagz @@ -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'] + } + } + } +} diff --git a/templates/tagz/small.tagz b/templates/tagz/small.tagz new file mode 100644 index 0000000..49a79f8 --- /dev/null +++ b/templates/tagz/small.tagz @@ -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 + } + } +}