slight-lang 1.0.1 → 1.0.5

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.
data/bin/slsh CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env ruby
2
- require_relative 'repl/repl.rb'
1
+ #!/usr/bin/env ruby
2
+ require_relative 'repl/repl.rb'
data/example/core.rb CHANGED
@@ -1,29 +1,29 @@
1
- $:.unshift File.expand_path('../../lib', __FILE__)
2
- require 'slight/dsl'
3
-
4
- module Slight
5
- class DSL
6
- def run
7
- doctype :html
8
- html do
9
- head do
10
- title "Example"
11
- use "/css/bootstrap.css"
12
- use "/script/jquery.js"
13
- use "/script/angular.js"
14
- end
15
- body do
16
- div "panel" do
17
- nav "nav nav-pill", id:"NavMenu", css:"color: red" do
18
- img! src:"/images/icon1.png"
19
- end
20
- end
21
- br
22
- hr
23
- end
24
- end
25
- end
26
- end
27
- end
28
-
29
- Slight::DSL.new(STDOUT).run
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'slight/dsl'
3
+
4
+ module Slight
5
+ class DSL
6
+ def run
7
+ doctype :html
8
+ html do
9
+ head do
10
+ title "Example"
11
+ use "/css/bootstrap.css"
12
+ use "/script/jquery.js"
13
+ use "/script/angular.js"
14
+ end
15
+ body do
16
+ div "panel" do
17
+ nav "nav nav-pill", id:"NavMenu", css:"color: red" do
18
+ img! src:"/images/icon1.png"
19
+ end
20
+ end
21
+ br
22
+ hr
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ Slight::DSL.new(STDOUT).run
@@ -1,37 +1,37 @@
1
- require 'slight/config'
2
- require 'slight/engine'
3
-
4
- module Slight
5
- class PrettyRender < Filter
6
- def self.do(src_data); end
7
- end
8
-
9
- class PrettyOutput < Filter
10
- end
11
-
12
- conf = Slight::Configuration.new do |c|
13
- c.use PrettyRender
14
- c.use PrettyOutput, :after
15
- #c.set :pretty_html, true
16
- end
17
-
18
- custom_engine = Slight::Engine.new(conf)
19
- io_out = STDOUT
20
-
21
- at_exit{
22
- io_out.close
23
- }
24
-
25
- begin
26
- raise IOError, "source file was not given." if ARGV.length == 0
27
- src_file = ARGV[0]
28
- io_out = File.open("#{ARGV[1]}", 'w') if ARGV.size == 2
29
- io_out.puts default_engine.render(src_file)
30
- rescue Exception => err
31
- STDERR.puts err.message
32
- STDERR.puts [err.inspect, err.backtrace.join("\n")].join("\n")
33
- exit 1
34
- end
35
-
36
- exit 0
37
- end
1
+ require 'slight/config'
2
+ require 'slight/engine'
3
+
4
+ module Slight
5
+ class PrettyRender < Filter
6
+ def self.do(src_data); end
7
+ end
8
+
9
+ class PrettyOutput < Filter
10
+ end
11
+
12
+ conf = Slight::Configuration.new do |c|
13
+ c.use PrettyRender
14
+ c.use PrettyOutput, :after
15
+ #c.set :pretty_html, true
16
+ end
17
+
18
+ custom_engine = Slight::Engine.new(conf)
19
+ io_out = STDOUT
20
+
21
+ at_exit{
22
+ io_out.close
23
+ }
24
+
25
+ begin
26
+ raise IOError, "source file was not given." if ARGV.length == 0
27
+ src_file = ARGV[0]
28
+ io_out = File.open("#{ARGV[1]}", 'w') if ARGV.size == 2
29
+ io_out.puts default_engine.render(src_file)
30
+ rescue Exception => err
31
+ STDERR.puts err.message
32
+ STDERR.puts [err.inspect, err.backtrace.join("\n")].join("\n")
33
+ exit 1
34
+ end
35
+
36
+ exit 0
37
+ end
@@ -1,28 +1,28 @@
1
- $:.unshift File.expand_path('../../lib', __FILE__)
2
- require 'slight'
3
-
4
- module Slight
5
- default_engine = Slight::Engine.new
6
- io_out = STDOUT
7
-
8
- at_exit{
9
- io_out.close
10
- }
11
-
12
- begin
13
- if ARGV[0] == "-v" then
14
- io_out.puts VERSION
15
- else
16
- raise IOError, "source file was not given." if ARGV.length == 0
17
- src_file = ARGV[0]
18
- io_out = File.open("#{ARGV[1]}", 'w') if ARGV.size == 2
19
- io_out.puts default_engine.render(src_file)
20
- end
21
- rescue Exception => err
22
- STDERR.puts err.message
23
- #STDERR.puts [err.inspect, err.backtrace.join("\n")].join("\n")
24
- exit 1
25
- end
26
-
27
- exit 0
28
- end
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'slight'
3
+
4
+ module Slight
5
+ default_engine = Slight::Engine.new
6
+ io_out = STDOUT
7
+
8
+ at_exit{
9
+ io_out.close
10
+ }
11
+
12
+ begin
13
+ if ARGV[0] == "-v" then
14
+ io_out.puts VERSION
15
+ else
16
+ raise IOError, "source file was not given." if ARGV.length == 0
17
+ src_file = ARGV[0]
18
+ io_out = File.open("#{ARGV[1]}", 'w') if ARGV.size == 2
19
+ io_out.puts default_engine.render(src_file)
20
+ end
21
+ rescue Exception => err
22
+ STDERR.puts err.message
23
+ #STDERR.puts [err.inspect, err.backtrace.join("\n")].join("\n")
24
+ exit 1
25
+ end
26
+
27
+ exit 0
28
+ end
@@ -1,33 +1,28 @@
1
- doctype :html
2
- html do
3
- head do
4
- title "Example"
5
- use "resource/css/bootstrap.css"
6
- use "resource/script/jquery.js"
7
- use "resource/script/angular.js"
8
- end
9
- body do
10
- div "panel" do
11
- nav "nav nav-pill", id:"NavMenu", css:"color: red" do
12
- img! src:"resource/images/icon1.png"
13
- end
14
- end
15
- div css:'border 1 bold blue' do
16
- layout_yield("#{File.dirname(__FILE__)}/component.slight.rb")
17
- end
18
- div css:'border 1 bold green' do
19
- layout_yield("#{File.dirname(__FILE__)}/component.slight.rb")
20
- end
21
- span do
22
- "Hello Span"
23
- end
24
- br
25
- hr
26
- end
27
-
28
- js %{
29
- let a =1;
30
- console.log(a);
31
- }
32
-
33
- end
1
+ doctype :html
2
+ html do
3
+ head do
4
+ title "Example"
5
+ use "resource/css/bootstrap.css"
6
+ use "resource/script/jquery.js"
7
+ end
8
+ body do
9
+ div "panel" do
10
+ nav "nav nav-pill", id:"NavMenu", css:"color: red" do
11
+ img! src:"resource/images/icon1.png"
12
+ end
13
+ end
14
+ div css:'border 1 bold blue' do
15
+ layout_yield("#{File.dirname(__FILE__)}/component.slight.rb")
16
+ end
17
+ div css:'border 1 bold green' do
18
+ layout_yield("#{File.dirname(__FILE__)}/component.slight.rb")
19
+ end
20
+ br
21
+ end
22
+
23
+ js %{
24
+ let a =1;
25
+ console.log(a);
26
+ }
27
+
28
+ end
@@ -0,0 +1,18 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'slight/tilt'
3
+
4
+ script = %q{
5
+ div "btn btn-succes #{btn_size}" do
6
+ @btn_txt
7
+ end
8
+ }
9
+
10
+ @btn_txt = 'Pls,Click-Me.'
11
+ body = Proc.new { script }
12
+
13
+ template = Tilt.new('tilt_example.rb', 5, {}, &body)
14
+ puts template.render(self, :btn_size => "btn-lg")
15
+
16
+ # <div class="btn btn-succes btn-lg">
17
+ # Pls,Click-Me.
18
+ # </div>
data/lib/slight/config.rb CHANGED
@@ -1,38 +1,39 @@
1
- module Slight
2
- class Configuration
3
- def initialize(options = {}, &blk)
4
- @options = options
5
- @options[:cus] ||= {}
6
- @options[:shortcutA] ||= {}
7
- @options[:shortcutT] ||= {}
8
- @options[:blinding] ||= {}
9
- @options[:before_filter] ||= []
10
- @options[:after_filter] ||= []
11
- blk.call self
12
- @options
13
- end
14
-
15
- def set(k, v); @options[:cus][k] = v; end
16
- def get(k); @options[:cus][k]; end
17
- def use(t, flag = :before)
18
- if flag == :before then
19
- @options[:before_filter].push(t)
20
- else
21
- @options[:after_filter].push(t)
22
- end
23
- end
24
-
25
- def shortcut(type, pattern, replacement)
26
- case(type)
27
- when :A
28
- @options[:shortcutA][pattern.to_sym] = replacement
29
- when :T
30
- @options[:shortcutT][pattern.to_sym] = replacement
31
- end
32
- end
33
-
34
- def blinding(*system_fun)
35
- @options[:blinding] = system_fun.map(&:to_sym)
36
- end
37
- end
38
- end
1
+ module Slight
2
+ class Configuration
3
+ def initialize(options = {}, &blk)
4
+ @options = options
5
+ @options[:cus] ||= {}
6
+ @options[:shortcutA] ||= {}
7
+ @options[:shortcutT] ||= {}
8
+ @options[:blinding] ||= {}
9
+ @options[:before_filter] ||= []
10
+ @options[:after_filter] ||= []
11
+ blk.call self
12
+ @options
13
+ end
14
+
15
+ def set(k, v); @options[:cus][k] = v; end
16
+ def get(k); @options[:cus][k]; end
17
+ def setIO(io_out); @options[:io_out] = io_out; end
18
+ def use(t, flag = :before)
19
+ if flag == :before then
20
+ @options[:before_filter].push(t)
21
+ else
22
+ @options[:after_filter].push(t)
23
+ end
24
+ end
25
+
26
+ def shortcut(type, pattern, replacement)
27
+ case(type)
28
+ when :A
29
+ @options[:shortcutA][pattern.to_sym] = replacement
30
+ when :T
31
+ @options[:shortcutT][pattern.to_sym] = replacement
32
+ end
33
+ end
34
+
35
+ def blinding(*system_fun)
36
+ @options[:blinding] = system_fun.map(&:to_sym)
37
+ end
38
+ end
39
+ end