wlang 2.2.3 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -21
- data/Gemfile.lock +47 -37
- data/LICENCE.md +17 -19
- data/README.md +47 -29
- data/lib/wlang/compiler/grammar.citrus +6 -6
- data/lib/wlang/dialect.rb +1 -1
- data/lib/wlang/loader.rb +0 -1
- data/lib/wlang/scope/sinatra_scope.rb +6 -1
- data/lib/wlang/template.rb +14 -13
- data/lib/wlang/tilt/wlang_template.rb +3 -2
- data/lib/wlang/version.rb +3 -3
- data/spec/fixtures/templates/front_matter.wlang +4 -0
- data/spec/unit/compiler/test_to_ruby_code.rb +2 -2
- data/spec/unit/source/test_path.rb +3 -3
- data/spec/unit/source/test_template_content.rb +1 -1
- data/spec/unit/template/test_path.rb +2 -2
- data/spec/unit/template/test_to_ruby_code.rb +1 -1
- data/spec/unit/test_assumptions.rb +1 -1
- data/spec/unit/tilt/test_wlang_template.rb +0 -4
- data/tasks/test.rake +17 -0
- data/wlang.gemspec +7 -169
- metadata +63 -155
- data/spec/integration/sinatra/test_partials.rb +0 -35
- data/tasks/debug_mail.rake +0 -75
- data/tasks/debug_mail.txt +0 -13
- data/tasks/spec_test.rake +0 -71
- data/tasks/unit_test.rake +0 -76
- data/tasks/yard.rake +0 -51
- data/wlang.noespec +0 -45
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e82a5d9c33a44f4d44068433fc341ac105eb6b0abb5859315264fc9c9039af3b
|
4
|
+
data.tar.gz: a3ed2db115e809a220e1e0046e8b60178e7c093e03c3ba0eb558ef3e24c6c356
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ccc8a54926e97ef4a4b4f8b49669f2ea3b1e2e4421900ebf4f4a05d1094b5121145f607b98d4e56ced1224e1c53f728df0028631058301bad315baab080ebce1
|
7
|
+
data.tar.gz: 95b57dc614446eddc46eb3eafec0a3b9470a3b440afdfd8ebf2c7c555aea3ae35ab34cdf6d4081e58b889a5c6057efc4d8767f694fd978a3b57fdd300559ceb0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# 3.0.1 / 2020-01-07
|
2
|
+
|
3
|
+
* Resurect Tilt/Sinatra support
|
4
|
+
|
5
|
+
# 3.0.0 / 2020-12-29
|
6
|
+
|
7
|
+
* Clean project to use a standard ruby-2.7 stack
|
8
|
+
* Upgrade citrus to 3.x
|
9
|
+
* Remove support for sinatra and tilt
|
10
|
+
|
11
|
+
# 2.2.4 / 2014-07-29
|
12
|
+
|
13
|
+
* Birthday of 2.2.3 :-)
|
14
|
+
* Under sinatra all partials now use the app.settings base options. Specified
|
15
|
+
dialect is in particular reused accross partials.
|
16
|
+
|
1
17
|
# 2.2.3 / 2013-07-29
|
2
18
|
|
3
19
|
* Bump Temple dependency to "~> 0.6"
|
data/Gemfile
CHANGED
@@ -1,22 +1,2 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
group :runtime do
|
4
|
-
gem "citrus", "~> 2.4.1"
|
5
|
-
gem "temple", "~> 0.6"
|
6
|
-
gem "quickl", "~> 0.4.3"
|
7
|
-
gem "path", "~> 1.3"
|
8
|
-
gem "backports", "~> 2.6"
|
9
|
-
end
|
10
|
-
|
11
|
-
group :extra do
|
12
|
-
gem "awesome_print", "~> 1.0.2"
|
13
|
-
end
|
14
|
-
|
15
|
-
group :development do
|
16
|
-
gem "tilt", "~> 1.3"
|
17
|
-
gem "rake", "~> 0.9.2"
|
18
|
-
gem "bundler", "~> 1.0"
|
19
|
-
gem "rspec", "~> 2.10.0"
|
20
|
-
gem "sinatra", ">= 1.4"
|
21
|
-
gem "rack-test", "~> 0.6"
|
22
|
-
end
|
2
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,46 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wlang (3.0.1)
|
5
|
+
citrus (~> 3.0)
|
6
|
+
path (~> 2.0)
|
7
|
+
quickl (~> 0.4.3)
|
8
|
+
temple (~> 0.6)
|
9
|
+
|
1
10
|
GEM
|
2
11
|
remote: http://rubygems.org/
|
3
12
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
path (
|
13
|
+
citrus (3.0.2)
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
mustermann (1.1.1)
|
16
|
+
ruby2_keywords (~> 0.0.1)
|
17
|
+
path (2.0.1)
|
9
18
|
quickl (0.4.3)
|
10
|
-
rack (
|
11
|
-
rack-protection (1.
|
19
|
+
rack (2.2.3)
|
20
|
+
rack-protection (2.1.0)
|
12
21
|
rack
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rspec-
|
18
|
-
|
19
|
-
rspec-
|
20
|
-
rspec-
|
21
|
-
|
22
|
-
|
23
|
-
rspec-mocks (
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
rake (13.0.3)
|
23
|
+
rspec (3.10.0)
|
24
|
+
rspec-core (~> 3.10.0)
|
25
|
+
rspec-expectations (~> 3.10.0)
|
26
|
+
rspec-mocks (~> 3.10.0)
|
27
|
+
rspec-core (3.10.1)
|
28
|
+
rspec-support (~> 3.10.0)
|
29
|
+
rspec-expectations (3.10.1)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-mocks (3.10.1)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-support (3.10.1)
|
36
|
+
ruby2_keywords (0.0.2)
|
37
|
+
sinatra (2.1.0)
|
38
|
+
mustermann (~> 1.0)
|
39
|
+
rack (~> 2.2)
|
40
|
+
rack-protection (= 2.1.0)
|
41
|
+
tilt (~> 2.0)
|
42
|
+
temple (0.8.2)
|
43
|
+
tilt (2.0.10)
|
30
44
|
|
31
45
|
PLATFORMS
|
32
|
-
|
46
|
+
x86_64-darwin-15
|
33
47
|
|
34
48
|
DEPENDENCIES
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
rspec (~> 2.10.0)
|
44
|
-
sinatra (>= 1.4)
|
45
|
-
temple (~> 0.6)
|
46
|
-
tilt (~> 1.3)
|
49
|
+
rake (~> 13.0)
|
50
|
+
rspec (~> 3.0)
|
51
|
+
sinatra (~> 2.1)
|
52
|
+
tilt (~> 2.0, >= 2.0.10)
|
53
|
+
wlang!
|
54
|
+
|
55
|
+
BUNDLED WITH
|
56
|
+
2.2.1
|
data/LICENCE.md
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
|
1
|
+
Copyright (c) 2012-2021 - Bernard Lambeau, Louis Lambeau
|
2
2
|
|
3
|
-
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,40 +1,50 @@
|
|
1
1
|
# WLang
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
|
5
|
-
WLang is a powerful code generation and templating engine, implemented on top
|
5
|
+
WLang is a powerful code generation and templating engine, implemented on top o
|
6
|
+
[temple](https://github.com/judofyr/temple) and much inspired by the excellent
|
7
|
+
[mustache](http://mustache.github.com/).
|
6
8
|
|
7
9
|
## Links
|
8
10
|
|
9
11
|
* http://github.com/blambeau/wlang
|
10
|
-
* http://blambeau.github.com/wlang
|
11
12
|
* http://rubygems.org/gems/wlang
|
12
13
|
* http://revision-zero.org/wlang
|
13
14
|
|
14
15
|
## Features
|
15
16
|
|
16
17
|
* Tunable templating engine. You can define your own tags, and their behavior.
|
17
|
-
* Powerful logic-less HTML concretization to render web pages à la Mustache
|
18
|
+
* Powerful logic-less HTML concretization to render web pages à la Mustache
|
19
|
+
with extra.
|
18
20
|
* Compiled templates for speedy generation.
|
19
|
-
* [Tilt](https://github.com/rtomayko/tilt) and [Sinatra](https://github.com/sinatra/sinatra) integration.
|
20
21
|
|
21
|
-
WLang
|
22
|
+
WLang 3.0 also has a few remaining issues.
|
22
23
|
|
23
|
-
* It
|
24
|
-
|
24
|
+
* It has some issues with spacing; not a big issue for HTML rendering but might
|
25
|
+
prevent certain generation tasks.
|
25
26
|
|
26
27
|
## Tunable templating engine
|
27
28
|
|
28
|
-
WLang is a templating engine, written in ruby. In that, it is similar to ERB,
|
29
|
+
WLang is a templating engine, written in ruby. In that, it is similar to ERB,
|
30
|
+
Mustache and the like:
|
29
31
|
|
30
32
|
```ruby
|
31
33
|
WLang::Html.render 'Hello to ${who}!', who: 'you & the world'
|
32
34
|
# => "Hello to you & the world!"
|
33
35
|
```
|
34
36
|
|
35
|
-
To output HTML pages, WLang does not provides you with killer features or
|
37
|
+
To output HTML pages, WLang does not provides you with killer features or
|
38
|
+
extraordinary shortcus. It supports escaping, as shown above, but many other
|
39
|
+
templating engines do. For such HTML tasks, WLang does a pretty good job but
|
40
|
+
many other engines perform faster and have nicer features. See the examples
|
41
|
+
folder that documents WLang::Html.
|
36
42
|
|
37
|
-
WLang is designed to help you for other uses cases, user-defined ones in
|
43
|
+
WLang is designed to help you for other uses cases, user-defined ones in
|
44
|
+
particular, such as generating code or whatever text generation task for
|
45
|
+
which other engines quickly become inappropriate. WLang helps there because
|
46
|
+
it allows you to create your own _dialect_, that is, you can define your own
|
47
|
+
tags and their behavior. For instance,
|
38
48
|
|
39
49
|
```ruby
|
40
50
|
class Highlighter < WLang::Dialect
|
@@ -47,11 +57,15 @@ class Highlighter < WLang::Dialect
|
|
47
57
|
|
48
58
|
tag '$', :highlight
|
49
59
|
end
|
50
|
-
Highlighter.render('Hello ${who}!'
|
60
|
+
Highlighter.render('Hello ${who}!', who: 'you & the world')
|
51
61
|
# => "Hello YOU & THE WORLD !"
|
52
62
|
```
|
53
63
|
|
54
|
-
WLang already provides a few useful dialects, such as WLang::Html
|
64
|
+
WLang already provides a few useful dialects, such as WLang::Html
|
65
|
+
(inspired by Mustache but a bit more powerful in my opinion). If they don't
|
66
|
+
match your needs, it is up to you to define you own dialect for making your
|
67
|
+
generation task easy. Have a look at the implementation of WLang's ones, it's
|
68
|
+
pretty simple to get started!
|
55
69
|
|
56
70
|
# Tilt integration
|
57
71
|
|
@@ -76,29 +90,33 @@ Please note that you should require tilt first, then wlang. Otherwise, you'll ha
|
|
76
90
|
|
77
91
|
WLang comes bundled with built-in support for [Sinatra](https://github.com/sinatra/sinatra) >= 1.4 (release still in progress). As usual in Sinatra, you can simply invoke wlang as follows:
|
78
92
|
|
79
|
-
|
80
|
-
|
81
|
-
|
93
|
+
```ruby
|
94
|
+
get '/' do
|
95
|
+
wlang :index, :locals => { ... }
|
96
|
+
end
|
97
|
+
```
|
82
98
|
|
83
99
|
As wlang encourages logic-less templates, you should always use locals. However, there is specific support for layouts and partials, as the following example demonstrates:
|
84
100
|
|
85
|
-
|
86
|
-
|
87
|
-
|
101
|
+
```ruby
|
102
|
+
get '/' do
|
103
|
+
wlang :index, :locals => {:who => "world"}
|
104
|
+
end
|
88
105
|
|
89
|
-
|
106
|
+
__END__
|
90
107
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
108
|
+
@@layout
|
109
|
+
<html>
|
110
|
+
>{yield}
|
111
|
+
</html>
|
95
112
|
|
96
|
-
|
97
|
-
|
113
|
+
@@index
|
114
|
+
Hello from a partial: >{partial}
|
98
115
|
|
99
|
-
|
100
|
-
|
116
|
+
@@partial
|
117
|
+
yeah, a partial saying hello to '${who}'!
|
101
118
|
|
102
119
|
Returned body will be (ignoring carriage returns):
|
103
120
|
|
104
|
-
|
121
|
+
<html>Hello from a partial: yeah, a partial saying hello to 'world'!</html>
|
122
|
+
```
|
@@ -2,7 +2,7 @@ grammar WLang::Grammar
|
|
2
2
|
|
3
3
|
rule template
|
4
4
|
(strconcat !.){
|
5
|
-
[:template, [:fn, strconcat.value]]
|
5
|
+
[:template, [:fn, capture(:strconcat).value]]
|
6
6
|
}
|
7
7
|
end
|
8
8
|
|
@@ -29,15 +29,15 @@ grammar WLang::Grammar
|
|
29
29
|
rule block
|
30
30
|
(fn_start strconcat fn_stop){
|
31
31
|
[:strconcat,
|
32
|
-
[:static,
|
33
|
-
|
34
|
-
[:static,
|
32
|
+
[:static, capture(:fn_start).to_s],
|
33
|
+
capture(:strconcat).value,
|
34
|
+
[:static, capture(:fn_stop).to_s]]
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
38
38
|
rule wlang
|
39
39
|
(symbols functions){
|
40
|
-
[:wlang, symbols.to_s] + functions.value
|
40
|
+
[:wlang, capture(:symbols).to_s] + capture(:functions).value
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
@@ -47,7 +47,7 @@ grammar WLang::Grammar
|
|
47
47
|
|
48
48
|
rule function
|
49
49
|
(fn_start strconcat fn_stop){
|
50
|
-
strconcat.value
|
50
|
+
capture(:strconcat).value
|
51
51
|
}
|
52
52
|
end
|
53
53
|
|
data/lib/wlang/dialect.rb
CHANGED
data/lib/wlang/loader.rb
CHANGED
@@ -27,7 +27,12 @@ module WLang
|
|
27
27
|
find_files(views, key) do |file|
|
28
28
|
if engine = Tilt[file]
|
29
29
|
tpl = app.template_cache.fetch(file) do
|
30
|
-
|
30
|
+
options = if app.settings.respond_to?(:wlang)
|
31
|
+
app.settings.wlang
|
32
|
+
else
|
33
|
+
{}
|
34
|
+
end
|
35
|
+
engine.new(file.to_s, 1, options)
|
31
36
|
end
|
32
37
|
return tpl
|
33
38
|
end
|
data/lib/wlang/template.rb
CHANGED
@@ -48,24 +48,25 @@ module WLang
|
|
48
48
|
scope, buffer = call_args_conventions(args)
|
49
49
|
dialect_instance.dup.render compiled, scope, buffer
|
50
50
|
end
|
51
|
+
|
51
52
|
alias :render :call
|
52
53
|
|
53
|
-
|
54
|
+
attr_reader :source, :compiled, :dialect_instance
|
54
55
|
|
55
|
-
|
56
|
+
private
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def yaml_front_matter?
|
59
|
+
opt = options[:yaml_front_matter]
|
60
|
+
opt.nil? or opt
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
def call_args_conventions(args)
|
64
|
+
args << '' unless args.last.respond_to?(:<<)
|
65
|
+
buffer = args.pop
|
66
|
+
args << self.locals unless self.locals.empty?
|
67
|
+
scope = WLang::Scope.chain(args)
|
68
|
+
[scope, buffer]
|
69
|
+
end
|
69
70
|
|
70
71
|
end # class Template
|
71
72
|
end # module WLang
|
@@ -16,7 +16,8 @@ module Tilt
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def default_options
|
19
|
-
|
19
|
+
@default_options ||= {}
|
20
|
+
(superclass.default_options rescue {}).merge(@default_options)
|
20
21
|
end
|
21
22
|
|
22
23
|
end
|
@@ -40,4 +41,4 @@ module Tilt
|
|
40
41
|
|
41
42
|
end
|
42
43
|
register WLangTemplate, 'wlang'
|
43
|
-
end
|
44
|
+
end
|