1
0

Add Handlebars

This commit is contained in:
2013-12-15 02:07:07 +07:00
parent d4ec63d52c
commit bcc555b585
8 changed files with 83 additions and 4 deletions
+1
View File
@@ -10,3 +10,4 @@ gem 'liquid'
gem 'mustache' gem 'mustache'
gem 'markaby' gem 'markaby'
gem 'tenjin' gem 'tenjin'
gem 'handlebars'
+12
View File
@@ -2,21 +2,32 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
builder (3.2.2) builder (3.2.2)
commonjs (0.2.7)
erubis (2.7.0) erubis (2.7.0)
faker (1.2.0) faker (1.2.0)
i18n (~> 0.5) i18n (~> 0.5)
haml (4.0.4) haml (4.0.4)
tilt tilt
handlebars (0.5.0)
commonjs (~> 0.2.3)
handlebars-source (~> 1.0.12)
therubyracer (~> 0.12.0)
handlebars-source (1.0.12)
i18n (0.6.9) i18n (0.6.9)
libv8 (3.16.14.3)
liquid (2.6.0) liquid (2.6.0)
markaby (0.7.2) markaby (0.7.2)
builder (>= 2.0.0) builder (>= 2.0.0)
mustache (0.99.5) mustache (0.99.5)
ref (1.0.5)
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)
temple (0.6.7) temple (0.6.7)
tenjin (0.7.1) tenjin (0.7.1)
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
tilt (2.0.0) tilt (2.0.0)
PLATFORMS PLATFORMS
@@ -26,6 +37,7 @@ DEPENDENCIES
erubis erubis
faker faker
haml haml
handlebars
liquid liquid
markaby markaby
mustache mustache
+1
View File
@@ -6,6 +6,7 @@
- [ERB](http://ruby-doc.org/stdlib-2.0.0/libdoc/erb/rdoc/ERB.html) - [ERB](http://ruby-doc.org/stdlib-2.0.0/libdoc/erb/rdoc/ERB.html)
- [Erubis](http://www.kuwata-lab.com/erubis/) - [Erubis](http://www.kuwata-lab.com/erubis/)
- [Haml](http://haml.info/) - [Haml](http://haml.info/)
- [Handlebars](https://github.com/cowboyd/handlebars.rb) (JS bingings)
- [Liquid](http://liquidmarkup.org/) - [Liquid](http://liquidmarkup.org/)
- [Markaby](http://markaby.github.io/) - [Markaby](http://markaby.github.io/)
- [Mustache](https://github.com/defunkt/mustache) - [Mustache](https://github.com/defunkt/mustache)
+8 -4
View File
@@ -9,10 +9,6 @@ $ ./fakedata.rb 10000 > data/big.yml
AGRR AGRR
Workbench::Benchmark.describe_engines( Workbench::Benchmark.describe_engines(
tenjin: {
class: Workbench::Wrappers::Tenjin,
extension: 'rbhtml'
},
string: { string: {
class: Tilt::StringTemplate, class: Tilt::StringTemplate,
extension: 'str' extension: 'str'
@@ -21,6 +17,10 @@ Workbench::Benchmark.describe_engines(
class: Tilt::ErubisTemplate, class: Tilt::ErubisTemplate,
extension: 'erubis' extension: 'erubis'
}, },
tenjin: {
class: Workbench::Wrappers::Tenjin,
extension: 'rbhtml'
},
erb: { erb: {
class: Tilt::ERBTemplate, class: Tilt::ERBTemplate,
extension: 'erb' extension: 'erb'
@@ -49,6 +49,10 @@ Workbench::Benchmark.describe_engines(
class: Tilt::BuilderTemplate, class: Tilt::BuilderTemplate,
extension: 'builder' extension: 'builder'
}, },
handlebars: {
class: Workbench::Wrappers::Handlebars,
extension: 'handlebars'
},
) )
templates = {} templates = {}
+2
View File
@@ -12,6 +12,7 @@ require 'slim'
require 'liquid' require 'liquid'
require 'mustache' require 'mustache'
require 'tenjin' require 'tenjin'
require 'handlebars'
require 'tilt/erb' require 'tilt/erb'
require 'tilt/erubis' require 'tilt/erubis'
require 'tilt/haml' require 'tilt/haml'
@@ -22,3 +23,4 @@ require 'workbench/wrappers/base'
require 'workbench/wrappers/mustache' require 'workbench/wrappers/mustache'
require 'workbench/wrappers/slim' require 'workbench/wrappers/slim'
require 'workbench/wrappers/tenjin' require 'workbench/wrappers/tenjin'
require 'workbench/wrappers/handlebars'
+16
View File
@@ -0,0 +1,16 @@
module Workbench
module Wrappers
class Handlebars < Base
@@context = ::Handlebars::Context.new
def initialize path
@engine = @@context.compile(File.read(path))
end
def render context, args = {}
@engine.call(args)
end
end
end
end
+25
View File
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>Customers List</title>
</head>
<body>
{{#each customers}}
<dl>
<dt>Name:</dt>
<dd>{{name}}</dd>
<dt>Age:</dt>
<dd>{{age}}</dd>
<dt>Address:</dt>
<dd>
{{zip}}
{{country}}
{{city}}
{{address}}
</dd>
<dt>Employer:</dt>
<dd>{{employer}}</dd>
</dl>
{{/each}}
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>{{window_title}}</title>
</head>
<body>
<h1>Hello, {{username}}!</h1>
<p>
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.
</p>
</body>
</html>