1
0
Fork 0

Add Handlebars

This commit is contained in:
Gregory Eremin 2013-12-15 02:07:07 +07:00
parent d4ec63d52c
commit bcc555b585
No known key found for this signature in database
GPG Key ID: 5EFA427EEC26E86C
8 changed files with 83 additions and 4 deletions

View File

@ -10,3 +10,4 @@ gem 'liquid'
gem 'mustache'
gem 'markaby'
gem 'tenjin'
gem 'handlebars'

View File

@ -2,21 +2,32 @@ GEM
remote: https://rubygems.org/
specs:
builder (3.2.2)
commonjs (0.2.7)
erubis (2.7.0)
faker (1.2.0)
i18n (~> 0.5)
haml (4.0.4)
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)
libv8 (3.16.14.3)
liquid (2.6.0)
markaby (0.7.2)
builder (>= 2.0.0)
mustache (0.99.5)
ref (1.0.5)
slim (2.0.2)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
temple (0.6.7)
tenjin (0.7.1)
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
tilt (2.0.0)
PLATFORMS
@ -26,6 +37,7 @@ DEPENDENCIES
erubis
faker
haml
handlebars
liquid
markaby
mustache

View File

@ -6,6 +6,7 @@
- [ERB](http://ruby-doc.org/stdlib-2.0.0/libdoc/erb/rdoc/ERB.html)
- [Erubis](http://www.kuwata-lab.com/erubis/)
- [Haml](http://haml.info/)
- [Handlebars](https://github.com/cowboyd/handlebars.rb) (JS bingings)
- [Liquid](http://liquidmarkup.org/)
- [Markaby](http://markaby.github.io/)
- [Mustache](https://github.com/defunkt/mustache)

View File

@ -9,10 +9,6 @@ $ ./fakedata.rb 10000 > data/big.yml
AGRR
Workbench::Benchmark.describe_engines(
tenjin: {
class: Workbench::Wrappers::Tenjin,
extension: 'rbhtml'
},
string: {
class: Tilt::StringTemplate,
extension: 'str'
@ -21,6 +17,10 @@ Workbench::Benchmark.describe_engines(
class: Tilt::ErubisTemplate,
extension: 'erubis'
},
tenjin: {
class: Workbench::Wrappers::Tenjin,
extension: 'rbhtml'
},
erb: {
class: Tilt::ERBTemplate,
extension: 'erb'
@ -49,6 +49,10 @@ Workbench::Benchmark.describe_engines(
class: Tilt::BuilderTemplate,
extension: 'builder'
},
handlebars: {
class: Workbench::Wrappers::Handlebars,
extension: 'handlebars'
},
)
templates = {}

View File

@ -12,6 +12,7 @@ require 'slim'
require 'liquid'
require 'mustache'
require 'tenjin'
require 'handlebars'
require 'tilt/erb'
require 'tilt/erubis'
require 'tilt/haml'
@ -22,3 +23,4 @@ require 'workbench/wrappers/base'
require 'workbench/wrappers/mustache'
require 'workbench/wrappers/slim'
require 'workbench/wrappers/tenjin'
require 'workbench/wrappers/handlebars'

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

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>

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>