slight-lang 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -132
  3. data/lib/slight.rb +3 -2
  4. data/slight.gemspec +1 -1
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c879ef00340954d40021fd0a09592e77e6a2ae64
4
- data.tar.gz: 3db13c8f77e7fa90297f6e449fae62cf25aacf43
3
+ metadata.gz: a2fb6397892fd342cc22a6e31478efbbc6ca5744
4
+ data.tar.gz: ec9f31523e9a92a671bdfb19b2ce05c943516855
5
5
  SHA512:
6
- metadata.gz: e1421b653fb2043448cdfcd18ea31206cca601173e6ceaae4c24fd7c1bcba09dba4177693da3ff367e928a6413ab3ea44c639ed8a9387b28b4c1b32632ae8dd1
7
- data.tar.gz: 207e469de27f2ac0a9dd9a020d993728ef8e3ff4f55ad0be4df624ad9cf0704c311be59b9df5fe7dc8001a1a3df87acf226d95e12754e531248005fc28c9f8b7
6
+ metadata.gz: e6928741a6d117a8d18cb48d8f94df7965edcf286147d9dc35b8d4adebf8e9d742125d4da0d0e93c48d94391becc0c66ecb9a9890429428eb977570e0826542b
7
+ data.tar.gz: '089f7d90260ad1b5c6712903621af6bba9fd48479b18f91dc73c4fab26be66cef920f6ec3854511e54eccdeb992b1ff949732fb378ad7098223069d52494ad98'
data/README.md CHANGED
@@ -1,12 +1,10 @@
1
1
  # Slight-lang
2
2
  A light and sweet template language.
3
3
 
4
- ## Description
5
- Slight is a very simple and easy to use template language.
6
- Advantage of Slight:
4
+ with:
7
5
  - Pure Ruby syntax
8
6
  - Html friendly
9
- - Nearly 0 learning cost
7
+ - 0 learning cost
10
8
 
11
9
  ## Quick Start
12
10
  #### [Installation]
@@ -14,33 +12,33 @@ Advantage of Slight:
14
12
  gem install slight-lang
15
13
 
16
14
  # you can also build gem from gemspec
17
- gem build slight.gemspec
18
- gem install ./slight-lang-1.0.1.gem
15
+ # gem build slight.gemspec
16
+ # gem install ./slight-lang-1.0.5.gem
19
17
  ```
20
18
 
21
- #### [Command]
22
- ###### Slight
19
+ #### [Usage]
20
+ ###### - Command
23
21
  ```bash
24
- slight [-v] <source> [<output>]
22
+ root@ubuntu: slight [-v] <source> [<output>]
25
23
 
26
- e.g.
27
- slight index.slight index.htm
28
- => index.htm
29
-
30
- slight index.slight
31
- => <tag>abcde</tag>
32
-
33
- slight -v
34
- => v 1.0.1
24
+ # slight index.slight index.htm
25
+ # => index.htm
35
26
  ```
36
27
 
37
- ###### REPL
38
- ```
39
- slsh
28
+ ###### - REPL
29
+ ```bash
30
+ root@ubuntu: slsh
40
31
  ```
41
- - build-in commands
42
-
43
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
+
44
42
  # help
45
43
  sl:> \h
46
44
  @file => load and compile file dynamically. E.g. @/tmp/page.slight
@@ -48,124 +46,67 @@ sl:> \h
48
46
  \eg => example
49
47
  \q => exit
50
48
  \v => show version (also: \ver, \version)
51
-
52
-
53
- # exit
54
- sl:> \q (ctrl + c)
55
- *** Exit now ***
56
- --bye--
57
-
58
-
59
- # show example
60
- sl:> \eg
61
- button "btn btn-primary" do
62
- "Click me"
63
- end
64
- =>
65
- <button class="btn btn-primary">Click me</button>
66
-
67
-
68
- # compile slight file
69
- sl:> @../../example/component.slight.rb
70
- LOAD PATH="../../example/component.slight.rb"
71
- <button class="btn btn-success btn-lg">
72
- submit</button>
73
-
74
-
75
- # redirect output to file
76
- sl:> >@output.htm (>@off to turn off)
77
- spool turned on
78
- OUTPUT PATH="output.htm"
79
- ```
80
- - Run Slight in REPL
81
-
82
- ```ruby
83
- sl:> button 'btn btn-success btn-lg', name:'btn_submit', type:'submit' do
84
- sl:> "Submit"
85
- sl:> end
86
- sl:> ; (Enter ';' to run the script)
87
-
88
- <button class="btn btn-success btn-lg" name="btn_submit" type="submit">
89
- Submit</button>
90
49
  ```
91
50
 
92
51
  #### [Syntax]
93
52
 
94
- - Pure Ruby Syntax
53
+ ###### - Pure Ruby Syntax
95
54
 
96
55
  ```ruby
97
56
  tag_name "class", [attributes: id, name, style, etc.] do; <content>; end
98
57
 
99
- e.g.
58
+ # example
100
59
  div "panel panel-lg", css: "border: 5 dotted green", id: "msgbox" do
101
60
  button "btn btn-primary" do
102
61
  "Ok"
103
62
  end
104
- button "btn btn-default" do
105
- "Cancel"
106
- end
107
63
  end
108
-
109
- (of course {} syntax is also spported)
110
64
  ```
111
- - All html tags are supported
65
+ ###### - HTML attributes and tags are naturally supported
112
66
 
113
- - Default Build-in Html Shortcuts
67
+ ###### - Support Shortcuts for HTML tags and attributes(can be customized)
114
68
 
115
- ```ruby
116
- [attribute]
117
- css => "style"
118
- ln => "href"
119
- url => "href"
120
- char => "charset"
121
- fn => "src"
122
- lang => "language"
123
- xn => "xmlns"
124
- mf => "manifest"
125
-
126
- e.g.
127
-
128
- div css:'border: 10 solid blue' do; "hello"; end
129
- =>
130
- <div style="border: 10 solid blue">
131
- Hello
132
- <div>
69
+ - Attribute Shortcuts
133
70
 
134
- [tag]
135
- _ => "<div>$content</div>"
136
- js => "<script language='javscript'>$content</script>"
137
- use => "<script type='text/javascript' src='$content'></script>"
138
- use => "<link rel='stylesheet' href='$content'></link>"
139
- # depends on which file loaded 'use' will determine which tag to replace.
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 |
140
77
 
141
- e.g.
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
+ ```
142
85
 
143
- _ do; "hello"; end
144
- =>
145
- <div>hello</div>
86
+ - Html Tag Shortcuts
146
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; |
147
94
 
95
+ ```ruby
96
+ # example
148
97
  js %{
149
98
  console.log("hello slight");
150
99
  }
151
- =>
152
- <script language="javascript">
153
- console.log("hello slight");
154
- </script>
155
-
100
+ # <script language="javascript">
101
+ # console.log("hello slight");
102
+ # </script>
156
103
 
157
104
  use 'resource/bootstrap.js'
158
- =>
159
- <script type='text/javascript' src='resource/bootstrap.js'></script>
160
-
161
-
162
- use 'resource/bootstrap.css'
163
- =>
164
- <link rel='stylesheet' href='resource/bootstrap.css'></link>
105
+ # <script type='text/javascript' src='resource/bootstrap.js'></script>
165
106
  ```
166
107
 
167
- #### [Customize]
168
- - general usage (more details please refer to example)
108
+ #### [Customization]
109
+ ###### - Usage (more details please refer to example)
169
110
 
170
111
  ```ruby
171
112
  conf = Slight::Configuration.new do |c|
@@ -176,29 +117,25 @@ end
176
117
  custom_engine = Slight::Engine.new(conf)
177
118
  ```
178
119
 
179
- - supported configuration
120
+ ###### - Configuration Options
180
121
 
181
122
  ```ruby
182
- conf = Slight::Configuration.new do |c|
183
- c.shortcut :A, :endpoint, "href" #add an attribute shortcut
184
- c.shortcut :T, "box", "div" #add a tag shotcut
185
-
186
- # set output IO
187
- c.setIO STDOUT
188
-
189
- # undef ruby methods in slight context
190
- c.blinding :p, :select, :puts, :send, :class
191
-
192
- # use Filter
193
- # Before-Filters accept original source pass the output to Slight compiler.
194
- # After-Filters accept output from Slight compiler pass the output to end user.
195
- c.use FilterA, :before
196
- c.use FilterB, :after
197
- end
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
198
134
  ```
199
135
 
200
- #### [Tilt]
201
- - Working with Tilt
136
+ #### [Tilt Intergration]
137
+
138
+ ##### Working with Tilt
202
139
  ```ruby
203
140
  require 'slight/tilt'
204
141
 
data/lib/slight.rb CHANGED
@@ -2,7 +2,8 @@ require 'slight/engine'
2
2
  module Slight
3
3
  # Slight version string
4
4
  # @api public
5
- VERSION = '1.0.5'
5
+ VERSION = '1.1.0'
6
6
  # 1.0.0 => Basic Template features | 201703
7
- # 1.0.5 => Support Tilt, Render Scope Binding | 201704
7
+ # 1.0.5 => Support Tilt | 201704
8
+ # 1.1.0 => Doc Update | 201705
8
9
  end
data/slight.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.authors = ["oliver.yu"]
7
7
  gem.email = ["nemo1023@gmail.com"]
8
8
  gem.description = %q{A light and sweet template language}
9
- gem.summary = %q{The goal of this is to use ruby syntax and html style shotcut to write template.}
9
+ gem.summary = %q{The goal of this is to use pure ruby syntax to write template.}
10
10
  gem.homepage = "https://github.com/OliversCat/Slight"
11
11
  gem.files = `git ls-files`.split($\)
12
12
  #gem.files = dir('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slight-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliver.yu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A light and sweet template language
14
14
  email:
@@ -67,5 +67,5 @@ rubyforge_project:
67
67
  rubygems_version: 2.6.11
68
68
  signing_key:
69
69
  specification_version: 4
70
- summary: The goal of this is to use ruby syntax and html style shotcut to write template.
70
+ summary: The goal of this is to use pure ruby syntax to write template.
71
71
  test_files: []