slight-lang 1.1.0 → 1.1.6

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
  SHA1:
3
- metadata.gz: a2fb6397892fd342cc22a6e31478efbbc6ca5744
4
- data.tar.gz: ec9f31523e9a92a671bdfb19b2ce05c943516855
3
+ metadata.gz: ffdab14abc2b396eed9e6263654efbc5fa3152d2
4
+ data.tar.gz: 50ceca22cfe183bf087bc32b0d66c24bc98fb2d7
5
5
  SHA512:
6
- metadata.gz: e6928741a6d117a8d18cb48d8f94df7965edcf286147d9dc35b8d4adebf8e9d742125d4da0d0e93c48d94391becc0c66ecb9a9890429428eb977570e0826542b
7
- data.tar.gz: '089f7d90260ad1b5c6712903621af6bba9fd48479b18f91dc73c4fab26be66cef920f6ec3854511e54eccdeb992b1ff949732fb378ad7098223069d52494ad98'
6
+ metadata.gz: e9827af78eedcf01007e9d1c68fa4974dae375265d1d777e0ea63347554941bcde1fccae5cb7b58201f125b7fb1645857f07c557e455ee8285f73814a35a7a71
7
+ data.tar.gz: 618de8def09c088e0dd6331e38f976cd37065774ffbe477adfee1878e5dc7de3a62652543e270e6d785245ff2292f46f2c2fe803cafc218f0dbf280ac6c1dcbd
data/.gitignore CHANGED
@@ -1 +1 @@
1
- *.gem
1
+ *.gem
data/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- The MIT License
2
-
3
- Copyright (c) 2016 Slight
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
22
-
1
+ The MIT License
2
+
3
+ Copyright (c) 2016 Slight
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
data/README.md CHANGED
@@ -1,160 +1,160 @@
1
- # Slight-lang
2
- A light and sweet template language.
3
-
4
- with:
5
- - Pure Ruby syntax
6
- - Html friendly
7
- - 0 learning cost
8
-
9
- ## Quick Start
10
- #### [Installation]
11
- ```
12
- gem install slight-lang
13
-
14
- # you can also build gem from gemspec
15
- # gem build slight.gemspec
16
- # gem install ./slight-lang-1.0.5.gem
17
- ```
18
-
19
- #### [Usage]
20
- ###### - Command
21
- ```bash
22
- root@ubuntu: slight [-v] <source> [<output>]
23
-
24
- # slight index.slight index.htm
25
- # => index.htm
26
- ```
27
-
28
- ###### - REPL
29
- ```bash
30
- root@ubuntu: slsh
31
- ```
32
- ```ruby
33
- sl:> button 'btn btn-success btn-lg', name:'btn_submit', type:'submit' do
34
- sl:> "Submit"
35
- sl:> end
36
- sl:> ; (Enter ';' to run the script)
37
-
38
- # compile from file
39
- sl:> @../../example/component.slight.rb
40
- LOAD PATH="../../example/component.slight.rb"
41
-
42
- # help
43
- sl:> \h
44
- @file => load and compile file dynamically. E.g. @/tmp/page.slight
45
- >@ => set output. E.g. Open: >@/tmp/output. Turn off: >@off
46
- \eg => example
47
- \q => exit
48
- \v => show version (also: \ver, \version)
49
- ```
50
-
51
- #### [Syntax]
52
-
53
- ###### - Pure Ruby Syntax
54
-
55
- ```ruby
56
- tag_name "class", [attributes: id, name, style, etc.] do; <content>; end
57
-
58
- # example
59
- div "panel panel-lg", css: "border: 5 dotted green", id: "msgbox" do
60
- button "btn btn-primary" do
61
- "Ok"
62
- end
63
- end
64
- ```
65
- ###### - HTML attributes and tags are naturally supported
66
-
67
- ###### - Support Shortcuts for HTML tags and attributes(can be customized)
68
-
69
- - Attribute Shortcuts
70
-
71
- | shortcut | attribute | shortcut | attribute |
72
- |-------|--------------| -------|--------------|
73
- | :css | style | :fn | src |
74
- | :ln | href | :lang | language |
75
- | :url | href | :xn | xmlns |
76
- | :char | charset | :mf | manifest |
77
-
78
- ```ruby
79
- # example
80
- div css:'border: 10 solid blue' do; "hello"; end
81
- # <div style="border: 10 solid blue">
82
- # Hello
83
- # <div>
84
- ```
85
-
86
- - Html Tag Shortcuts
87
-
88
- | shortcut | attribute |
89
- |-------|--------------|
90
- | _ | &lt;div&gt;$content&lt;/div&gt; |
91
- | js | &lt;script language='javscript'&gt;$content&lt;/script&gt; |
92
- | use | &lt;script type='text/javascript' src='$content'&gt;&lt;/script&gt; |
93
- | use | &lt;link rel='stylesheet' href='$content'&gt;&lt;/link&gt; |
94
-
95
- ```ruby
96
- # example
97
- js %{
98
- console.log("hello slight");
99
- }
100
- # <script language="javascript">
101
- # console.log("hello slight");
102
- # </script>
103
-
104
- use 'resource/bootstrap.js'
105
- # <script type='text/javascript' src='resource/bootstrap.js'></script>
106
- ```
107
-
108
- #### [Customization]
109
- ###### - Usage (more details please refer to example)
110
-
111
- ```ruby
112
- conf = Slight::Configuration.new do |c|
113
- c.shortcut :A, :endpoint, "href" #add an attribute shortcut
114
- c.shortcut :T, "box", "div" #add a tag shortcut
115
- end
116
-
117
- custom_engine = Slight::Engine.new(conf)
118
- ```
119
-
120
- ###### - Configuration Options
121
-
122
- ```ruby
123
- shortcut :A, :endpoint, "href" #add an attribute shortcut
124
- shortcut :T, "box", "div" #add a tag shortcut
125
- # set output IO
126
- setIO STDOUT
127
- # undef ruby methods in slight context
128
- blinding :p, :select, :puts, :send, :class
129
- # use Filter
130
- # Before-Filters accept original source pass the output to Slight compiler.
131
- # After-Filters accept output from Slight compiler pass the output to end user.
132
- use FilterA, :before
133
- use FilterB, :after
134
- ```
135
-
136
- #### [Tilt Intergration]
137
-
138
- ##### Working with Tilt
139
- ```ruby
140
- require 'slight/tilt'
141
-
142
- script = %q{
143
- div "btn btn-succes #{btn_size}" do
144
- @btn_txt
145
- end
146
- }
147
-
148
- @btn_txt = 'Pls,Click-Me.'
149
- body = Proc.new { script }
150
-
151
- template = Tilt.new('tilt_example.rb', 5, {}, &body)
152
- puts template.render(self, :btn_size => "btn-lg")
153
-
154
- # <div class="btn btn-succes btn-lg">
155
- # Pls,Click-Me.
156
- # </div>
157
- ```
158
-
159
-
160
- Any questions or suggestions are welcome. You can reach me at: nemo1023#gmail.com
1
+ # Slight-lang
2
+ A light and sweet template language.
3
+
4
+ with:
5
+ - Pure Ruby syntax
6
+ - Html friendly
7
+ - 0 learning cost
8
+
9
+ ## Quick Start
10
+ #### [Installation]
11
+ ```
12
+ gem install slight-lang
13
+
14
+ # you can also build gem from gemspec
15
+ # gem build slight.gemspec
16
+ # gem install ./slight-lang-1.0.5.gem
17
+ ```
18
+
19
+ #### [Usage]
20
+ ###### - Command
21
+ ```bash
22
+ root@ubuntu: slight [-v] <source> [<output>]
23
+
24
+ # slight index.slight index.htm
25
+ # => index.htm
26
+ ```
27
+
28
+ ###### - REPL
29
+ ```bash
30
+ root@ubuntu: slsh
31
+ ```
32
+ ```ruby
33
+ sl:> button 'btn btn-success btn-lg', name:'btn_submit', type:'submit' do
34
+ sl:> "Submit"
35
+ sl:> end
36
+ sl:> ; (Enter ';' to run the script)
37
+
38
+ # compile from file
39
+ sl:> @../../example/component.slight.rb
40
+ LOAD PATH="../../example/component.slight.rb"
41
+
42
+ # help
43
+ sl:> \h
44
+ @file => load and compile file dynamically. E.g. @/tmp/page.slight
45
+ >@ => set output. E.g. Open: >@/tmp/output. Turn off: >@off
46
+ \eg => example
47
+ \q => exit
48
+ \v => show version (also: \ver, \version)
49
+ ```
50
+
51
+ #### [Syntax]
52
+
53
+ ###### - Pure Ruby Syntax
54
+
55
+ ```ruby
56
+ tag_name "class", [attributes: id, name, style, etc.] do; <content>; end
57
+
58
+ # example
59
+ div "panel panel-lg", css: "border: 5 dotted green", id: "msgbox" do
60
+ button "btn btn-primary" do
61
+ "Ok"
62
+ end
63
+ end
64
+ ```
65
+ ###### - HTML attributes and tags are naturally supported
66
+
67
+ ###### - Support Shortcuts for HTML tags and attributes(can be customized)
68
+
69
+ - Attribute Shortcuts
70
+
71
+ | shortcut | attribute | shortcut | attribute |
72
+ |-------|--------------| -------|--------------|
73
+ | :css | style | :fn | src |
74
+ | :ln | href | :lang | language |
75
+ | :url | href | :xn | xmlns |
76
+ | :char | charset | :mf | manifest |
77
+
78
+ ```ruby
79
+ # example
80
+ div css:'border: 10 solid blue' do; "hello"; end
81
+ # <div style="border: 10 solid blue">
82
+ # Hello
83
+ # <div>
84
+ ```
85
+
86
+ - Html Tag Shortcuts
87
+
88
+ | shortcut | attribute |
89
+ |-------|--------------|
90
+ | _ | &lt;div&gt;$content&lt;/div&gt; |
91
+ | js | &lt;script language='javscript'&gt;$content&lt;/script&gt; |
92
+ | use | &lt;script type='text/javascript' src='$content'&gt;&lt;/script&gt; |
93
+ | use | &lt;link rel='stylesheet' href='$content'&gt;&lt;/link&gt; |
94
+
95
+ ```ruby
96
+ # example
97
+ js %{
98
+ console.log("hello slight");
99
+ }
100
+ # <script language="javascript">
101
+ # console.log("hello slight");
102
+ # </script>
103
+
104
+ use 'resource/bootstrap.js'
105
+ # <script type='text/javascript' src='resource/bootstrap.js'></script>
106
+ ```
107
+
108
+ #### [Customization]
109
+ ###### - Usage (more details please refer to example)
110
+
111
+ ```ruby
112
+ conf = Slight::Configuration.new do |c|
113
+ c.shortcut :A, :endpoint, "href" #add an attribute shortcut
114
+ c.shortcut :T, "box", "div" #add a tag shortcut
115
+ end
116
+
117
+ custom_engine = Slight::Engine.new(conf)
118
+ ```
119
+
120
+ ###### - Configuration Options
121
+
122
+ ```ruby
123
+ shortcut :A, :endpoint, "href" #add an attribute shortcut
124
+ shortcut :T, "box", "div" #add a tag shortcut
125
+ # set output IO
126
+ setIO STDOUT
127
+ # undef ruby methods in slight context
128
+ blinding :p, :select, :puts, :send, :class
129
+ # use Filter
130
+ # Before-Filters accept original source pass the output to Slight compiler.
131
+ # After-Filters accept output from Slight compiler pass the output to end user.
132
+ use FilterA, :before
133
+ use FilterB, :after
134
+ ```
135
+
136
+ #### [Tilt Intergration]
137
+
138
+ ##### Working with Tilt
139
+ ```ruby
140
+ require 'slight/tilt'
141
+
142
+ script = %q{
143
+ div "btn btn-succes #{btn_size}" do
144
+ @btn_txt
145
+ end
146
+ }
147
+
148
+ @btn_txt = 'Pls,Click-Me.'
149
+ body = Proc.new { script }
150
+
151
+ template = Tilt.new('tilt_example.rb', 5, {}, &body)
152
+ puts template.render(self, :btn_size => "btn-lg")
153
+
154
+ # <div class="btn btn-succes btn-lg">
155
+ # Pls,Click-Me.
156
+ # </div>
157
+ ```
158
+
159
+
160
+ Any questions or suggestions are welcome. You can reach me at: nemo1023#gmail.com