1
0
Fork 0

Add Parkaby implementation, sadly it has no gem specification

This commit is contained in:
Gregory Eremin 2013-12-15 02:45:26 +07:00
parent f4d39d98cb
commit 9becb386fb
No known key found for this signature in database
GPG Key ID: 5EFA427EEC26E86C
8 changed files with 86 additions and 19 deletions

View File

@ -11,3 +11,5 @@ gem 'mustache'
gem 'markaby' gem 'markaby'
gem 'tenjin' gem 'tenjin'
gem 'handlebars' gem 'handlebars'
# gem 'liquor'
# gem 'parkaby', github: 'judofyr/parkaby'

View File

@ -53,6 +53,10 @@ Workbench::Benchmark.describe_engines(
class: Workbench::Wrappers::Handlebars, class: Workbench::Wrappers::Handlebars,
extension: 'handlebars' extension: 'handlebars'
}, },
# parkaby: {
# class: Workbench::Wrappers::Parkaby,
# extension: 'mab'
# },
) )
templates = {} templates = {}

View File

@ -13,6 +13,7 @@ require 'liquid'
require 'mustache' require 'mustache'
require 'tenjin' require 'tenjin'
require 'handlebars' require 'handlebars'
# require 'parkaby'
require 'tilt/erb' require 'tilt/erb'
require 'tilt/erubis' require 'tilt/erubis'
require 'tilt/haml' require 'tilt/haml'
@ -24,3 +25,4 @@ require 'workbench/wrappers/mustache'
require 'workbench/wrappers/slim' require 'workbench/wrappers/slim'
require 'workbench/wrappers/tenjin' require 'workbench/wrappers/tenjin'
require 'workbench/wrappers/handlebars' require 'workbench/wrappers/handlebars'
require 'workbench/wrappers/parkaby'

View File

@ -0,0 +1,14 @@
module Workbench
module Wrappers
class Parkaby < Base
def initialize path
@engine = ::Parkaby::Template.string(File.read(path))
end
def render context, args = {}
@engine.render(OpenStruct.new(args))
end
end
end
end

View File

@ -1,26 +1,26 @@
html do html {
head do head {
title 'Customers List' title 'Customers List'
end }
body do body {
customers.each do |customer| customers.each do |customer|
dl do dl {
dt 'Name:' dt 'Name:'
dd customer['name'] dd customer['name']
dt 'Age:' dt 'Age:'
dd customer['age'] dd customer['age']
dt 'Address:' dt 'Address:'
dd do dd {
[ [
customer['zip'], customer['zip'],
customer['country'], customer['country'],
customer['city'], customer['city'],
customer['address'] customer['address']
].join("\n") ].join("\n")
end }
dt 'Employer:' dt 'Employer:'
dd customer['employer'] dd customer['employer']
end }
end }
end }
end }

View File

@ -1,10 +1,10 @@
html do html {
head do head {
title window_title title window_title
end }
body do body {
h1 "Hello, #{username}!" h1 "Hello, #{username}!"
p do p {
<<-END <<-END
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
@ -14,6 +14,6 @@ html do
occaecat cupidatat non proident, sunt in culpa qui officia deserunt occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum. mollit anim id est laborum.
END END
end }
end }
end }

26
templates/parkaby/big.mab Normal file
View File

@ -0,0 +1,26 @@
html {
head {
title 'Customers List'
}
body {
customers.each do |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']
}
}
}
}

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
}
}
}