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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1676affa8a6c17cb3a067f44f136d486175eb9929991cb45eff8f6f2cc6a5866
4
- data.tar.gz: 74fde3634a89fd89673b511c7498450127ca4e4a28217e1a13be4d616d4d9d45
3
+ metadata.gz: 0c8f17e5bb94d82ff20787118208ba1fd022e81920f9ba2bc5fd7200317dd53a
4
+ data.tar.gz: 4744f42da1f657f6dd3cffa27492f9ade9f9e5e6ab89b6d4b4645eff7db7dc7c
5
5
  SHA512:
6
- metadata.gz: 4ae08e930afd613d01ad6a6ca0fffc7283a30c9ab43f5b2b60c32cfe5890f0d768583d794e8e2abdbacc82618f42fd7a01e72f2107c6424a425f2b0c1ae77d1b
7
- data.tar.gz: 1f53eef7a9caa329b86df4f25523e9d08a8380d30aac46c991d0d6bf45a48ba803d17d29dacb9d95ab425f11c53d218f0d4acd9c03280f777d23f2294fadaa27
6
+ metadata.gz: 27fcbafde0589969ec31561299701a415b71ce78fd459b29a237ba5e995ba7519c4eb6c140e74ee3302789d15b758b5e561b67c16dd36dad394618df0c4d8cc1
7
+ data.tar.gz: 8cbfca9d51ae4fc88b790a83621b9e5d7d94a85a42ce7a5e63d8bb10e554e38d470350148d707a07cc486d80770ab1b828864d4829c989b8cff05e8bb652795a
@@ -2,4 +2,6 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.0
5
- before_install: gem update bundler
5
+ before_install:
6
+ - gem update --system
7
+ - gem update bundler
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
- Please take a look at the tests for actual examples.
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 986.519 i/100ms
52
- string 1.614k i/100ms
92
+ erb 993.525 i/100ms
93
+ string 1.911k i/100ms
53
94
  Calculating -------------------------------------
54
- erb 10.598k i/s - 49.325k in 4.654229s
55
- string 19.550k i/s - 80.686k in 4.127156s
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: 19550.0 i/s
59
- erb: 10597.9 i/s - 1.84x slower
99
+ string: 22028.7 i/s
100
+ erb: 11011.5 i/s - 2.00x slower
60
101
  ```
61
102
 
62
103
 
@@ -3,7 +3,7 @@
3
3
  module StringTemplate
4
4
  class Handler
5
5
  def self.call(template)
6
- "%Q[#{template.source}]"
6
+ "%Q\0#{template.source}\0"
7
7
  end
8
8
 
9
9
  def self.handles_encoding?
@@ -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.1.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 = 'String is your template engine'
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.1.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: String is your template engine
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: []