hmote 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/hmote.rb +5 -5
- data/lib/hmote/version.rb +3 -1
- data/test/helper.rb +2 -0
- data/test/helpers_test.rb +2 -0
- data/test/parsing_test.rb +10 -5
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574d79f437faf44b5337ddfdb727ed3ab7097404
|
4
|
+
data.tar.gz: b3f511a6f9913a4f62e66a8d673b9a72ec74a597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c7b07826c01235d9100c64a1ca0faf8edbdfcb938809ad69168d75b1dab2dbd7c74b88a6e09fe5f507ec4f36092d573829a0c8fdd7aec2a0eccd3b65ee445aa
|
7
|
+
data.tar.gz: 7eb8fc99e77be61ce15089e2c9b870167406dd38ee05bd694a79bb248327034bd36294c3e93b2eaca92dbccf3a73f41f3b2418a74eb8cee790a7a44bbe9fa881
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
hmote [![Build Status](https://gitlab.com/frodsan/hmote/badges/master/build.svg)](https://gitlab.com/frodsan/hmote/builds)
|
2
2
|
=====
|
3
3
|
|
4
4
|
Minimal template engine with default escaping.
|
@@ -6,7 +6,7 @@ Minimal template engine with default escaping.
|
|
6
6
|
Description
|
7
7
|
-----------
|
8
8
|
|
9
|
-
|
9
|
+
hmote is a fork of [Mote][mote] that uses [Hache][hache]
|
10
10
|
to auto-escape HTML special characters.
|
11
11
|
|
12
12
|
Installation
|
@@ -43,13 +43,13 @@ template.call
|
|
43
43
|
# => "your template goes here!"
|
44
44
|
```
|
45
45
|
|
46
|
-
|
46
|
+
hmote recognizes three tags to evaluate Ruby code: `%`, `{{}}` and `<? ?>`.
|
47
47
|
The difference between them is that while the `%` and `<? ?>` tags only
|
48
48
|
evaluate the code, the `{{}}` tag also prints the result to the template.
|
49
49
|
|
50
50
|
Imagine that your template looks like this:
|
51
51
|
|
52
|
-
```
|
52
|
+
```
|
53
53
|
% # single-line code
|
54
54
|
% gems = ["rack", "cuba", "hmote"]
|
55
55
|
|
@@ -98,7 +98,7 @@ template.call(name: "Ruby")
|
|
98
98
|
Auto-escaping
|
99
99
|
-------------
|
100
100
|
|
101
|
-
By default,
|
101
|
+
By default, hmote escapes HTML special characters to prevent [XSS][xss]
|
102
102
|
attacks. You can start the expression with an exclamation mark to disable
|
103
103
|
escaping for that expression:
|
104
104
|
|
@@ -151,7 +151,7 @@ hmote("foo.mote", a: 1, b: 2)
|
|
151
151
|
Related projects:
|
152
152
|
-----------------
|
153
153
|
|
154
|
-
- [hmote-render][hmote-render]:
|
154
|
+
- [hmote-render][hmote-render]: hmote plugin for Cuba.
|
155
155
|
|
156
156
|
Contributing
|
157
157
|
------------
|
@@ -159,7 +159,7 @@ Contributing
|
|
159
159
|
Fork the project with:
|
160
160
|
|
161
161
|
```
|
162
|
-
$ git clone git@
|
162
|
+
$ git clone git@gitlab.com:frodsan/hmote.git
|
163
163
|
```
|
164
164
|
|
165
165
|
To install dependencies, use:
|
@@ -174,16 +174,16 @@ To run the test suite, do:
|
|
174
174
|
$ rake test
|
175
175
|
```
|
176
176
|
|
177
|
-
For bug reports and pull requests use [
|
177
|
+
For bug reports and pull requests use [GitLab][issues].
|
178
178
|
|
179
179
|
License
|
180
180
|
-------
|
181
181
|
|
182
|
-
|
182
|
+
hmote is released under the [MIT License][mit].
|
183
183
|
|
184
184
|
[mit]: http://www.opensource.org/licenses/MIT
|
185
185
|
[mote]: https://github.com/soveran/mote
|
186
|
-
[hache]: https://
|
186
|
+
[hache]: https://gitlab.com/frodsan/hache
|
187
187
|
[hmote-render]: https://github.com/harmoni/hmote-render
|
188
|
-
[issues]: https://
|
188
|
+
[issues]: https://gitlab.com/frodsan/hmote/issues
|
189
189
|
[xss]: http://en.wikipedia.org/wiki/Cross-Site_Scripting
|
data/lib/hmote.rb
CHANGED
@@ -47,11 +47,11 @@ class HMote
|
|
47
47
|
|
48
48
|
def self.parse_expression(terms, term)
|
49
49
|
case term
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
when "<?" then terms.shift + "\n"
|
51
|
+
when "%" then terms.shift + "\n"
|
52
|
+
when "{{" then "__o << Hache.h((" + terms.shift + ").to_s)\n"
|
53
|
+
when "{{!" then "__o << (" + terms.shift + ").to_s\n"
|
54
|
+
else "__o << " + term.dump + "\n"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
data/lib/hmote/version.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/helpers_test.rb
CHANGED
data/test/parsing_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "helper"
|
2
4
|
|
3
5
|
class ParsingTest < Minitest::Test
|
@@ -8,7 +10,7 @@ class ParsingTest < Minitest::Test
|
|
8
10
|
end
|
9
11
|
|
10
12
|
test "control flow" do
|
11
|
-
template =
|
13
|
+
template = <<-EOT.gsub(/ {4}/, "")
|
12
14
|
% if false
|
13
15
|
false
|
14
16
|
% else
|
@@ -22,7 +24,7 @@ class ParsingTest < Minitest::Test
|
|
22
24
|
end
|
23
25
|
|
24
26
|
test "parameters" do
|
25
|
-
template =
|
27
|
+
template = <<-EOT.gsub(/ {4}/, "")
|
26
28
|
% params[:n].times do
|
27
29
|
*
|
28
30
|
% end
|
@@ -46,7 +48,10 @@ class ParsingTest < Minitest::Test
|
|
46
48
|
|
47
49
|
test "context" do
|
48
50
|
context = Object.new
|
49
|
-
|
51
|
+
|
52
|
+
def context.user
|
53
|
+
"Bruno"
|
54
|
+
end
|
50
55
|
|
51
56
|
example = HMote.parse("{{ user }}", context)
|
52
57
|
|
@@ -66,7 +71,7 @@ class ParsingTest < Minitest::Test
|
|
66
71
|
end
|
67
72
|
|
68
73
|
test "multi-line XML-style directives" do
|
69
|
-
template =
|
74
|
+
template = <<-EOT.gsub(/^ /, "")
|
70
75
|
<?
|
71
76
|
# Multiline code evaluation
|
72
77
|
lucky = [1, 3, 7, 9, 13, 15]
|
@@ -81,7 +86,7 @@ class ParsingTest < Minitest::Test
|
|
81
86
|
end
|
82
87
|
|
83
88
|
test "preserve XML directives" do
|
84
|
-
template =
|
89
|
+
template = <<-EOT.gsub(/^ /, "")
|
85
90
|
<?xml "hello" ?>
|
86
91
|
EOT
|
87
92
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hmote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodríguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hache
|
@@ -66,8 +66,22 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.39'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.39'
|
69
83
|
description: A minimum operational template that escapes HTML tags by default
|
70
|
-
email: frodsan@
|
84
|
+
email: frodsan@hello.com
|
71
85
|
executables: []
|
72
86
|
extensions: []
|
73
87
|
extra_rdoc_files: []
|
@@ -79,7 +93,7 @@ files:
|
|
79
93
|
- test/helper.rb
|
80
94
|
- test/helpers_test.rb
|
81
95
|
- test/parsing_test.rb
|
82
|
-
homepage: https://
|
96
|
+
homepage: https://gitlab.com/frodsan/hmote
|
83
97
|
licenses:
|
84
98
|
- MIT
|
85
99
|
metadata: {}
|