wlang 2.2.3 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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
@@ -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
- awesome_print (1.0.2)
5
- backports (2.8.2)
6
- citrus (2.4.1)
7
- diff-lcs (1.1.3)
8
- path (1.3.1)
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 (1.5.2)
11
- rack-protection (1.5.0)
19
+ rack (2.2.3)
20
+ rack-protection (2.1.0)
12
21
  rack
13
- rack-test (0.6.2)
14
- rack (>= 1.0)
15
- rake (0.9.6)
16
- rspec (2.10.0)
17
- rspec-core (~> 2.10.0)
18
- rspec-expectations (~> 2.10.0)
19
- rspec-mocks (~> 2.10.0)
20
- rspec-core (2.10.1)
21
- rspec-expectations (2.10.0)
22
- diff-lcs (~> 1.1.3)
23
- rspec-mocks (2.10.1)
24
- sinatra (1.4.2)
25
- rack (~> 1.5, >= 1.5.2)
26
- rack-protection (~> 1.4)
27
- tilt (~> 1.3, >= 1.3.4)
28
- temple (0.6.5)
29
- tilt (1.3.7)
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
- ruby
46
+ x86_64-darwin-15
33
47
 
34
48
  DEPENDENCIES
35
- awesome_print (~> 1.0.2)
36
- backports (~> 2.6)
37
- bundler (~> 1.0)
38
- citrus (~> 2.4.1)
39
- path (~> 1.3)
40
- quickl (~> 0.4.3)
41
- rack-test (~> 0.6)
42
- rake (~> 0.9.2)
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
- # The MIT Licence
1
+ Copyright (c) 2012-2021 - Bernard Lambeau, Louis Lambeau
2
2
 
3
- Copyright (c) 2012 - Bernard Lambeau, Louis Lambeau
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
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
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
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
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
- [![Build Status](https://secure.travis-ci.org/blambeau/wlang.png?branch=wlang2)](http://travis-ci.org/blambeau/wlang)
3
+ ![](https://travis-ci.org/blambeau/wlang.svg?branch=master)
4
4
 
5
- WLang is a powerful code generation and templating engine, implemented on top of [temple](https://github.com/judofyr/temple) and much inspired by the excellent [mustache](http://mustache.github.com/).
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 with extra.
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 2.0 also has a few remaining issues.
22
+ WLang 3.0 also has a few remaining issues.
22
23
 
23
- * It does not support rubinius so far, due to an incompatibility with the Citrus parser generator.
24
- * It has some issues with spacing; not a big issue for HTML rendering but might prevent certain generation tasks.
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, Mustache and the like:
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 &amp; the world!"
33
35
  ```
34
36
 
35
- To output HTML pages, WLang does not provides you with killer features or extraordinary shortcus. It supports escaping, as shown above, but many other templating engines do. For such HTML tasks, WLang does a pretty good job but many other engines perform faster and have nicer features. See the examples folder that documents WLang::Html.
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 particular, such as generating code or whatever text generation task for which other engines quickly become inappropriate. WLang helps there because it allows you to create your own _dialect_, that is, you can define your own tags and their behavior. For instance,
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}!'), who: 'you & the world'
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 (inspired by Mustache but a bit more powerful in my opinion). If they don't match your needs, it is up to you to define you own dialect for making your generation task easy. Have a look at the implementation of WLang's ones, it's pretty simple to get started!
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
- get '/' do
80
- wlang :index, :locals => { ... }
81
- end
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
- get '/' do
86
- wlang :index, :locals => {:who => "world"}
87
- end
101
+ ```ruby
102
+ get '/' do
103
+ wlang :index, :locals => {:who => "world"}
104
+ end
88
105
 
89
- __END__
106
+ __END__
90
107
 
91
- @@layout
92
- <html>
93
- >{yield}
94
- </html>
108
+ @@layout
109
+ <html>
110
+ >{yield}
111
+ </html>
95
112
 
96
- @@index
97
- Hello from a partial: >{partial}
113
+ @@index
114
+ Hello from a partial: >{partial}
98
115
 
99
- @@partial
100
- yeah, a partial saying hello to '${who}'!
116
+ @@partial
117
+ yeah, a partial saying hello to '${who}'!
101
118
 
102
119
  Returned body will be (ignoring carriage returns):
103
120
 
104
- <html>Hello from a partial: yeah, a partial saying hello to 'world'!</html>
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, captures[:fn_start].first.to_s],
33
- captures[:strconcat].first.value,
34
- [:static, captures[:fn_stop].first.to_s]]
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
 
@@ -161,7 +161,7 @@ module WLang
161
161
 
162
162
  # Returns the current rendering scope.
163
163
  def scope
164
- @scope || Scope.null
164
+ @scope ||= Scope.null
165
165
  end
166
166
 
167
167
  # Yields the block with a scope branched with a sub-scope `x`.
@@ -2,4 +2,3 @@ require "citrus"
2
2
  require "temple"
3
3
  require "quickl"
4
4
  require "path"
5
- require 'backports' if RUBY_VERSION < "1.9"
@@ -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
- engine.new(file.to_s, 1, {})
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
@@ -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
- private
54
+ attr_reader :source, :compiled, :dialect_instance
54
55
 
55
- attr_reader :source, :compiled, :dialect_instance
56
+ private
56
57
 
57
- def yaml_front_matter?
58
- opt = options[:yaml_front_matter]
59
- opt.nil? or opt
60
- end
58
+ def yaml_front_matter?
59
+ opt = options[:yaml_front_matter]
60
+ opt.nil? or opt
61
+ end
61
62
 
62
- def call_args_conventions(args)
63
- args << '' unless args.last.respond_to?(:<<)
64
- buffer = args.pop
65
- args << self.locals unless self.locals.empty?
66
- scope = WLang::Scope.chain(args)
67
- [scope, buffer]
68
- end
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
- (superclass.default_options rescue {}).merge(@default_options || {})
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
@@ -1,9 +1,9 @@
1
1
  module WLang
2
2
  module Version
3
3
 
4
- MAJOR = 2
5
- MINOR = 2
6
- TINY = 3
4
+ MAJOR = 3
5
+ MINOR = 0
6
+ TINY = 1
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')