Add string interpolation
This commit is contained in:
parent
41d073b785
commit
babdc13c79
46
README.md
46
README.md
|
@ -15,44 +15,50 @@ bundle install
|
|||
```
|
||||
|
||||
## Current Results
|
||||
** Intel Core i7 2.6 GHz **
|
||||
|
||||
```
|
||||
############################################################
|
||||
## Compilation (small) (1000 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
erb 0.250000 0.030000 0.280000 ( 0.275828)
|
||||
erubis 0.060000 0.020000 0.080000 ( 0.077510)
|
||||
haml 0.860000 0.030000 0.890000 ( 0.892039)
|
||||
slim 1.960000 0.030000 1.990000 ( 1.989972)
|
||||
liquid 0.060000 0.020000 0.080000 ( 0.074439)
|
||||
string 0.040000 0.010000 0.050000 ( 0.054310)
|
||||
erb 0.240000 0.030000 0.270000 ( 0.260111)
|
||||
erubis 0.060000 0.010000 0.070000 ( 0.078122)
|
||||
haml 0.850000 0.030000 0.880000 ( 0.873031)
|
||||
slim 1.930000 0.030000 1.960000 ( 1.960224)
|
||||
liquid 0.050000 0.020000 0.070000 ( 0.073867)
|
||||
|
||||
############################################################
|
||||
## Render (small) (1000 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
erb 0.010000 0.000000 0.010000 ( 0.012331)
|
||||
erubis 0.010000 0.000000 0.010000 ( 0.008456)
|
||||
haml 0.020000 0.000000 0.020000 ( 0.027852)
|
||||
slim 0.030000 0.000000 0.030000 ( 0.021398)
|
||||
liquid 0.030000 0.000000 0.030000 ( 0.037635)
|
||||
string 0.010000 0.000000 0.010000 ( 0.013322)
|
||||
erb 0.010000 0.000000 0.010000 ( 0.012137)
|
||||
erubis 0.010000 0.000000 0.010000 ( 0.008176)
|
||||
haml 0.020000 0.000000 0.020000 ( 0.021298)
|
||||
slim 0.020000 0.000000 0.020000 ( 0.022210)
|
||||
liquid 0.030000 0.000000 0.030000 ( 0.036494)
|
||||
|
||||
############################################################
|
||||
## Compilation (big) (1000 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
erb 0.330000 0.020000 0.350000 ( 0.352752)
|
||||
erubis 0.120000 0.020000 0.140000 ( 0.139981)
|
||||
haml 1.200000 0.030000 1.230000 ( 1.226896)
|
||||
slim 2.440000 0.030000 2.470000 ( 2.469225)
|
||||
liquid 0.120000 0.020000 0.140000 ( 0.133451)
|
||||
string 0.060000 0.020000 0.080000 ( 0.071830)
|
||||
erb 0.300000 0.020000 0.320000 ( 0.324309)
|
||||
erubis 0.120000 0.020000 0.140000 ( 0.140036)
|
||||
haml 1.180000 0.030000 1.210000 ( 1.203810)
|
||||
slim 2.410000 0.030000 2.440000 ( 2.441857)
|
||||
liquid 0.120000 0.010000 0.130000 ( 0.134647)
|
||||
|
||||
############################################################
|
||||
## Render (big) (100 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
erb 0.650000 0.020000 0.670000 ( 0.667166)
|
||||
erubis 0.430000 0.010000 0.440000 ( 0.446348)
|
||||
haml 0.970000 0.020000 0.990000 ( 0.993755)
|
||||
slim 1.440000 0.010000 1.450000 ( 1.445460)
|
||||
liquid 10.660000 0.050000 10.710000 ( 10.715820)
|
||||
string 0.390000 0.030000 0.420000 ( 0.414645)
|
||||
erb 0.650000 0.020000 0.670000 ( 0.666250)
|
||||
erubis 0.430000 0.010000 0.440000 ( 0.448594)
|
||||
haml 0.970000 0.020000 0.990000 ( 0.981991)
|
||||
slim 1.400000 0.010000 1.410000 ( 1.408893)
|
||||
liquid 10.480000 0.050000 10.530000 ( 10.535895)
|
||||
```
|
||||
|
|
|
@ -52,6 +52,10 @@ def benchmark params
|
|||
end
|
||||
|
||||
ENGINES = {
|
||||
string: {
|
||||
class: Tilt::StringTemplate,
|
||||
extension: 'str'
|
||||
},
|
||||
erb: {
|
||||
class: Tilt::ERBTemplate,
|
||||
extension: 'erb'
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Customers List</title>
|
||||
</head>
|
||||
<body>
|
||||
#{ customers.map do |customer|
|
||||
<<-END
|
||||
<dl>
|
||||
<dt>Name:</dt>
|
||||
<dd>#{customer['name']}</dd>
|
||||
<dt>Age:</dt>
|
||||
<dd>#{customer['age']}</dd>
|
||||
<dt>Address:</dt>
|
||||
<dd>
|
||||
#{customer['zip']}
|
||||
#{customer['country']}
|
||||
#{customer['city']}
|
||||
#{customer['address']}
|
||||
</dd>
|
||||
<dt>Employer:</dt>
|
||||
<dd>#{customer['employer']}</dd>
|
||||
</dl>
|
||||
END
|
||||
end.join }
|
||||
<% end %>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>#{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>
|
Loading…
Reference in New Issue