string_template 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/README.md +49 -8
- data/lib/string_template/handler.rb +1 -1
- data/string_template.gemspec +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c8f17e5bb94d82ff20787118208ba1fd022e81920f9ba2bc5fd7200317dd53a
|
4
|
+
data.tar.gz: 4744f42da1f657f6dd3cffa27492f9ade9f9e5e6ab89b6d4b4645eff7db7dc7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27fcbafde0589969ec31561299701a415b71ce78fd459b29a237ba5e995ba7519c4eb6c140e74ee3302789d15b758b5e561b67c16dd36dad394618df0c4d8cc1
|
7
|
+
data.tar.gz: 8cbfca9d51ae4fc88b790a83621b9e5d7d94a85a42ce7a5e63d8bb10e554e38d470350148d707a07cc486d80770ab1b828864d4829c989b8cff05e8bb652795a
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,48 @@ And then execute:
|
|
27
27
|
|
28
28
|
StringTemplate's syntax is based on Ruby's String interpolation.
|
29
29
|
Plus, you can use Action View features.
|
30
|
-
|
30
|
+
|
31
|
+
### Example
|
32
|
+
Here's an example of a scaffold generated ERB template, and its string\_template version.
|
33
|
+
|
34
|
+
ERB:
|
35
|
+
```
|
36
|
+
<p id="notice"><%= notice %></p>
|
37
|
+
|
38
|
+
<p>
|
39
|
+
<strong>Title:</strong>
|
40
|
+
<%= @post.title %>
|
41
|
+
</p>
|
42
|
+
|
43
|
+
<p>
|
44
|
+
<strong>Body:</strong>
|
45
|
+
<%= @post.body %>
|
46
|
+
</p>
|
47
|
+
|
48
|
+
<%= link_to 'Edit', "/posts/#{@post.id}/edit" %> |
|
49
|
+
<%= link_to 'Back', '/posts' %>
|
50
|
+
```
|
51
|
+
|
52
|
+
string\_template:
|
53
|
+
```
|
54
|
+
<p id="notice">#{ notice }</p>
|
55
|
+
|
56
|
+
<p>
|
57
|
+
<strong>Title:</strong>
|
58
|
+
#{ @post.title }
|
59
|
+
</p>
|
60
|
+
|
61
|
+
<p>
|
62
|
+
<strong>Body:</strong>
|
63
|
+
#{ @post.body }
|
64
|
+
</p>
|
65
|
+
|
66
|
+
#{ link_to 'Edit', "/posts/#{@post.id}/edit" } |
|
67
|
+
#{ link_to 'Back', '/posts' }
|
68
|
+
```
|
69
|
+
|
70
|
+
# More Examples
|
71
|
+
Please take a look at [the tests](https://github.com/amatsuda/string_template/blob/master/test/string_template_test.rb) for actual examples.
|
31
72
|
|
32
73
|
|
33
74
|
## Filenames
|
@@ -42,21 +83,21 @@ For other templates, you might better use your favorite template engine such as
|
|
42
83
|
|
43
84
|
|
44
85
|
## Benchmark
|
45
|
-
Following is the benchmark result showing how string\_template is faster than ERB, executed on Ruby trunk (2.6).
|
86
|
+
Following is the benchmark result showing how string\_template is faster than ERB (Erubi, to be technically accurate), executed on Ruby trunk (2.6).
|
46
87
|
This repo includes [this actual benchmarking script](https://github.com/amatsuda/string_template/blob/master/benchmark.rb) so that you can try it on your machine.
|
47
88
|
|
48
89
|
```
|
49
90
|
% ruby benchmark.rb
|
50
91
|
Warming up --------------------------------------
|
51
|
-
erb
|
52
|
-
string 1.
|
92
|
+
erb 993.525 i/100ms
|
93
|
+
string 1.911k i/100ms
|
53
94
|
Calculating -------------------------------------
|
54
|
-
erb
|
55
|
-
string
|
95
|
+
erb 11.012k i/s - 49.676k in 4.511268s
|
96
|
+
string 22.029k i/s - 95.529k in 4.336571s
|
56
97
|
|
57
98
|
Comparison:
|
58
|
-
string:
|
59
|
-
erb:
|
99
|
+
string: 22028.7 i/s
|
100
|
+
erb: 11011.5 i/s - 2.00x slower
|
60
101
|
```
|
61
102
|
|
62
103
|
|
data/string_template.gemspec
CHANGED
@@ -3,12 +3,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "string_template"
|
6
|
-
spec.version = '0.
|
6
|
+
spec.version = '0.2.0'
|
7
7
|
spec.authors = ["Akira Matsuda"]
|
8
8
|
spec.email = ["ronnie@dio.jp"]
|
9
9
|
|
10
10
|
spec.summary = "A template engine for Rails, focusing on speed, using Ruby's String interpolation syntax"
|
11
|
-
spec.description =
|
11
|
+
spec.description = %]string_template is a Rails plugin that adds an Action View handler for .string template that accepts Ruby's String literal that uses #{} notation for interpolating dynamic variables]
|
12
12
|
spec.homepage = 'https://github.com/amatsuda/string_template'
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string_template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
@@ -80,7 +80,9 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description: string_template is a Rails plugin that adds an Action View handler for
|
84
|
+
.string template that accepts Ruby's String literal that uses notation for interpolating
|
85
|
+
dynamic variables
|
84
86
|
email:
|
85
87
|
- ronnie@dio.jp
|
86
88
|
executables: []
|