zafu 0.5.0 → 0.6.0
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/History.txt +11 -0
- data/Rakefile +2 -1
- data/lib/zafu/all.rb +6 -4
- data/lib/zafu/controller_methods.rb +27 -18
- data/lib/zafu/info.rb +1 -1
- data/lib/zafu/markup.rb +87 -25
- data/lib/zafu/node_context.rb +48 -4
- data/lib/zafu/ordered_hash.rb +47 -0
- data/lib/zafu/parser.rb +140 -55
- data/lib/zafu/parsing_rules.rb +49 -17
- data/lib/zafu/process/ajax.rb +344 -66
- data/lib/zafu/process/conditional.rb +36 -25
- data/lib/zafu/process/context.rb +101 -4
- data/lib/zafu/process/forms.rb +124 -0
- data/lib/zafu/process/html.rb +78 -83
- data/lib/zafu/process/ruby_less_processing.rb +248 -0
- data/lib/zafu/test_helper.rb +1 -1
- data/lib/zafu/view_methods.rb +6 -0
- data/test/markup_test.rb +150 -8
- data/test/mock/classes.rb +24 -0
- data/test/mock/core_ext.rb +9 -0
- data/test/mock/params.rb +4 -10
- data/test/mock/process.rb +7 -0
- data/test/mock/test_compiler.rb +9 -0
- data/test/node_context_test.rb +135 -46
- data/test/ordered_hash_test.rb +69 -0
- data/test/ruby_less_test.rb +29 -19
- data/test/test_helper.rb +4 -3
- data/test/zafu/ajax.yml +7 -0
- data/test/zafu/asset.yml +3 -0
- data/test/zafu/basic.yml +3 -0
- data/test/zafu/markup.yml +4 -0
- data/test/zafu/meta.yml +8 -0
- data/test/zafu/security.yml +19 -0
- data/test/zafu_test.rb +29 -12
- data/zafu.gemspec +28 -6
- metadata +41 -8
- data/lib/zafu/process/ruby_less.rb +0 -145
data/test/ruby_less_test.rb
CHANGED
@@ -1,34 +1,44 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class ZafuRubyLessTest < Test::Unit::TestCase
|
4
|
-
include RubyLess
|
5
|
-
|
4
|
+
include RubyLess
|
5
|
+
def self.process_unknown(callback); end;
|
6
|
+
include Zafu::Process::RubyLessProcessing
|
6
7
|
def helper; self.class; end
|
7
8
|
safe_method :one => {:class => String, :method => "main_one"}
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
context 'With a Markup' do
|
12
|
+
setup do
|
13
|
+
@markup = Zafu::Markup.new('p')
|
12
14
|
end
|
13
|
-
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
context 'parsing an attribute without dynamic strings' do
|
17
|
+
should 'not alter string' do
|
18
|
+
set_markup_attr(@markup, :name, 'this is a string')
|
19
|
+
assert_equal '<p name=\'this is a string\'>foo</p>', @markup.wrap('foo')
|
20
|
+
end
|
18
21
|
end
|
19
22
|
|
20
|
-
context 'with
|
21
|
-
should '
|
22
|
-
|
23
|
-
|
24
|
-
end
|
23
|
+
context 'parsing an attribute with dynamic content' do
|
24
|
+
should 'use RubyLess to translate content' do
|
25
|
+
set_markup_attr(@markup, :name, 'this #{one}')
|
26
|
+
assert_equal '<p name=\'<%= "this #{main_one}" %>\'>foo</p>', @markup.wrap('foo')
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
context 'with ruby errors' do
|
30
|
+
should 'raise a RubyLess::SyntaxError' do
|
31
|
+
assert_raises(RubyLess::SyntaxError) do
|
32
|
+
set_markup_attr(@markup, :name, 'this #{one}}')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
should 'produce an error message with the original attribute' do
|
37
|
+
begin
|
38
|
+
set_markup_attr(@markup, :name, 'this #{one}}')
|
39
|
+
rescue RubyLess::Error => err
|
40
|
+
assert_match %r{parse error on value "\}" \(tRCURLY\)}, err.message
|
41
|
+
end
|
32
42
|
end
|
33
43
|
end
|
34
44
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,8 +2,9 @@ require 'rubygems'
|
|
2
2
|
require 'stringio'
|
3
3
|
require 'test/unit'
|
4
4
|
require 'shoulda'
|
5
|
+
require 'yamltest'
|
5
6
|
require 'zafu'
|
6
7
|
require 'zafu/test_helper'
|
7
|
-
require '
|
8
|
-
|
9
|
-
|
8
|
+
require 'zafu/ordered_hash'
|
9
|
+
require 'mock/test_compiler'
|
10
|
+
require 'mock/core_ext'
|
data/test/zafu/ajax.yml
ADDED
data/test/zafu/asset.yml
ADDED
data/test/zafu/basic.yml
ADDED
data/test/zafu/meta.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
some_template:
|
2
|
+
src: "<div id='a'>a</div><div id='b'>b</div>"
|
3
|
+
tem: "<div id='a'>a</div><div id='b'>b</div>"
|
4
|
+
|
5
|
+
include_with_part:
|
6
|
+
# part 'a' is moved around
|
7
|
+
src: "<r:include template='/some/template'><r:with part='a'/><r:with part='b'>new b:<r:include template='/some/template' part='a'/></r:with></r:include>"
|
8
|
+
tem: "<div id='b'>new b:<div id='a'>a</div></div>"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
nasty_erb:
|
2
|
+
src: "this <% puts \"could be\" %> nasty"
|
3
|
+
tem: "this <% puts \"could be\" %> nasty"
|
4
|
+
|
5
|
+
never_end_erb:
|
6
|
+
src: "never ending erb <%= puts "
|
7
|
+
tem: "never ending erb <%= puts "
|
8
|
+
|
9
|
+
nasty_evil_erb:
|
10
|
+
src: "this <% puts <% puts 'could be' %> %> nasty"
|
11
|
+
tem: "this <% puts <% puts 'could be' %> %> nasty"
|
12
|
+
|
13
|
+
trick_erb:
|
14
|
+
src: "this <<r:void/>% puts 'is bad' %>"
|
15
|
+
tem: "this <<r:void/>% puts 'is bad' %>"
|
16
|
+
|
17
|
+
include_erb:
|
18
|
+
src: "include: <r:include template='/nasty_erb'/>"
|
19
|
+
tem: "include: this <% puts \"could be\" %> nasty"
|
data/test/zafu_test.rb
CHANGED
@@ -7,12 +7,12 @@ class String
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class ZafuTest < Test::Unit::TestCase
|
10
|
-
include RubyLess
|
10
|
+
include RubyLess
|
11
11
|
include Zafu::TestHelper
|
12
12
|
safe_method :one => {:class => String, :method => "main_one"}
|
13
|
-
|
13
|
+
|
14
14
|
class Dummy
|
15
|
-
include RubyLess
|
15
|
+
include RubyLess
|
16
16
|
safe_method :hello => String
|
17
17
|
safe_method :one => {:class => String, :method => "dummy_one"}
|
18
18
|
end
|
@@ -42,16 +42,33 @@ class ZafuTest < Test::Unit::TestCase
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
|
46
|
+
# ========== YAML TESTS
|
47
|
+
|
48
|
+
yamltest
|
49
|
+
|
50
|
+
def get_template_text(path, base_path)
|
51
|
+
folder = base_path.blank? ? [] : base_path.split('/')
|
52
|
+
url = (folder + path[1..-1].split('/'))
|
53
|
+
|
54
|
+
|
55
|
+
file = url.shift
|
56
|
+
test_name = url.join('_')
|
57
|
+
|
58
|
+
if test = @@test_strings[file][test_name]
|
59
|
+
# text, absolute_url, base_path
|
60
|
+
[test['src'], (file + test_name), file]
|
61
|
+
else
|
62
|
+
nil
|
54
63
|
end
|
55
64
|
end
|
56
65
|
|
66
|
+
def yt_do_test(file, test)
|
67
|
+
url = "/#{file}/#{test}"
|
68
|
+
tem = @@test_strings[file][test]['tem']
|
69
|
+
ast = TestCompiler.new_with_url(url, :helper => self)
|
70
|
+
yt_assert tem, ast.to_erb(:node => Zafu::NodeContext.new('@node', Page), :helper => self)
|
71
|
+
end
|
72
|
+
|
73
|
+
yt_make
|
57
74
|
end
|
data/zafu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{zafu}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gaspard Bucher"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-27}
|
13
13
|
s.description = %q{Provides a powerful templating language based on xhtml for rails}
|
14
14
|
s.email = %q{gaspard@teti.ch}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,24 +29,38 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/zafu/markup.rb",
|
30
30
|
"lib/zafu/mock_helper.rb",
|
31
31
|
"lib/zafu/node_context.rb",
|
32
|
+
"lib/zafu/ordered_hash.rb",
|
32
33
|
"lib/zafu/parser.rb",
|
33
34
|
"lib/zafu/parsing_rules.rb",
|
34
35
|
"lib/zafu/process/ajax.rb",
|
35
36
|
"lib/zafu/process/conditional.rb",
|
36
37
|
"lib/zafu/process/context.rb",
|
38
|
+
"lib/zafu/process/forms.rb",
|
37
39
|
"lib/zafu/process/html.rb",
|
38
|
-
"lib/zafu/process/
|
40
|
+
"lib/zafu/process/ruby_less_processing.rb",
|
39
41
|
"lib/zafu/template.rb",
|
40
42
|
"lib/zafu/test_helper.rb",
|
43
|
+
"lib/zafu/view_methods.rb",
|
41
44
|
"rails/init.rb",
|
42
45
|
"script/console",
|
43
46
|
"script/destroy",
|
44
47
|
"script/generate",
|
45
48
|
"test/markup_test.rb",
|
49
|
+
"test/mock/classes.rb",
|
50
|
+
"test/mock/core_ext.rb",
|
46
51
|
"test/mock/params.rb",
|
52
|
+
"test/mock/process.rb",
|
53
|
+
"test/mock/test_compiler.rb",
|
47
54
|
"test/node_context_test.rb",
|
55
|
+
"test/ordered_hash_test.rb",
|
48
56
|
"test/ruby_less_test.rb",
|
49
57
|
"test/test_helper.rb",
|
58
|
+
"test/zafu/ajax.yml",
|
59
|
+
"test/zafu/asset.yml",
|
60
|
+
"test/zafu/basic.yml",
|
61
|
+
"test/zafu/markup.yml",
|
62
|
+
"test/zafu/meta.yml",
|
63
|
+
"test/zafu/security.yml",
|
50
64
|
"test/zafu_test.rb",
|
51
65
|
"zafu.gemspec"
|
52
66
|
]
|
@@ -57,8 +71,13 @@ Gem::Specification.new do |s|
|
|
57
71
|
s.summary = %q{Provides a powerful templating language based on xhtml for rails}
|
58
72
|
s.test_files = [
|
59
73
|
"test/markup_test.rb",
|
74
|
+
"test/mock/classes.rb",
|
75
|
+
"test/mock/core_ext.rb",
|
60
76
|
"test/mock/params.rb",
|
77
|
+
"test/mock/process.rb",
|
78
|
+
"test/mock/test_compiler.rb",
|
61
79
|
"test/node_context_test.rb",
|
80
|
+
"test/ordered_hash_test.rb",
|
62
81
|
"test/ruby_less_test.rb",
|
63
82
|
"test/test_helper.rb",
|
64
83
|
"test/zafu_test.rb"
|
@@ -70,14 +89,17 @@ Gem::Specification.new do |s|
|
|
70
89
|
|
71
90
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
72
91
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
73
|
-
s.
|
92
|
+
s.add_development_dependency(%q<yamltest>, [">= 0.5.0"])
|
93
|
+
s.add_runtime_dependency(%q<rubyless>, [">= 0.5.0"])
|
74
94
|
else
|
75
95
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
76
|
-
s.add_dependency(%q<
|
96
|
+
s.add_dependency(%q<yamltest>, [">= 0.5.0"])
|
97
|
+
s.add_dependency(%q<rubyless>, [">= 0.5.0"])
|
77
98
|
end
|
78
99
|
else
|
79
100
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
80
|
-
s.add_dependency(%q<
|
101
|
+
s.add_dependency(%q<yamltest>, [">= 0.5.0"])
|
102
|
+
s.add_dependency(%q<rubyless>, [">= 0.5.0"])
|
81
103
|
end
|
82
104
|
end
|
83
105
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 6
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gaspard Bucher
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-27 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
type: :development
|
31
31
|
version_requirements: *id001
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
|
-
name:
|
33
|
+
name: yamltest
|
34
34
|
prerelease: false
|
35
35
|
requirement: &id002 !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
@@ -38,11 +38,25 @@ dependencies:
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
segments:
|
40
40
|
- 0
|
41
|
-
-
|
41
|
+
- 5
|
42
42
|
- 0
|
43
|
-
version: 0.
|
44
|
-
type: :
|
43
|
+
version: 0.5.0
|
44
|
+
type: :development
|
45
45
|
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rubyless
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
- 5
|
56
|
+
- 0
|
57
|
+
version: 0.5.0
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id003
|
46
60
|
description: Provides a powerful templating language based on xhtml for rails
|
47
61
|
email: gaspard@teti.ch
|
48
62
|
executables: []
|
@@ -65,24 +79,38 @@ files:
|
|
65
79
|
- lib/zafu/markup.rb
|
66
80
|
- lib/zafu/mock_helper.rb
|
67
81
|
- lib/zafu/node_context.rb
|
82
|
+
- lib/zafu/ordered_hash.rb
|
68
83
|
- lib/zafu/parser.rb
|
69
84
|
- lib/zafu/parsing_rules.rb
|
70
85
|
- lib/zafu/process/ajax.rb
|
71
86
|
- lib/zafu/process/conditional.rb
|
72
87
|
- lib/zafu/process/context.rb
|
88
|
+
- lib/zafu/process/forms.rb
|
73
89
|
- lib/zafu/process/html.rb
|
74
|
-
- lib/zafu/process/
|
90
|
+
- lib/zafu/process/ruby_less_processing.rb
|
75
91
|
- lib/zafu/template.rb
|
76
92
|
- lib/zafu/test_helper.rb
|
93
|
+
- lib/zafu/view_methods.rb
|
77
94
|
- rails/init.rb
|
78
95
|
- script/console
|
79
96
|
- script/destroy
|
80
97
|
- script/generate
|
81
98
|
- test/markup_test.rb
|
99
|
+
- test/mock/classes.rb
|
100
|
+
- test/mock/core_ext.rb
|
82
101
|
- test/mock/params.rb
|
102
|
+
- test/mock/process.rb
|
103
|
+
- test/mock/test_compiler.rb
|
83
104
|
- test/node_context_test.rb
|
105
|
+
- test/ordered_hash_test.rb
|
84
106
|
- test/ruby_less_test.rb
|
85
107
|
- test/test_helper.rb
|
108
|
+
- test/zafu/ajax.yml
|
109
|
+
- test/zafu/asset.yml
|
110
|
+
- test/zafu/basic.yml
|
111
|
+
- test/zafu/markup.yml
|
112
|
+
- test/zafu/meta.yml
|
113
|
+
- test/zafu/security.yml
|
86
114
|
- test/zafu_test.rb
|
87
115
|
- zafu.gemspec
|
88
116
|
has_rdoc: true
|
@@ -117,8 +145,13 @@ specification_version: 3
|
|
117
145
|
summary: Provides a powerful templating language based on xhtml for rails
|
118
146
|
test_files:
|
119
147
|
- test/markup_test.rb
|
148
|
+
- test/mock/classes.rb
|
149
|
+
- test/mock/core_ext.rb
|
120
150
|
- test/mock/params.rb
|
151
|
+
- test/mock/process.rb
|
152
|
+
- test/mock/test_compiler.rb
|
121
153
|
- test/node_context_test.rb
|
154
|
+
- test/ordered_hash_test.rb
|
122
155
|
- test/ruby_less_test.rb
|
123
156
|
- test/test_helper.rb
|
124
157
|
- test/zafu_test.rb
|
@@ -1,145 +0,0 @@
|
|
1
|
-
require 'rubyless'
|
2
|
-
|
3
|
-
module Zafu
|
4
|
-
module Process
|
5
|
-
module RubyLess
|
6
|
-
include ::RubyLess::SafeClass
|
7
|
-
# Actual method resolution. The lookup first starts in the current helper. If nothing is found there, it
|
8
|
-
# searches inside a 'helpers' module and finally looks into the current node_context.
|
9
|
-
# If nothing is found at this stage, we prepend the method with the current node and start over again.
|
10
|
-
def safe_method_type(signature)
|
11
|
-
get_method_type(signature, false)
|
12
|
-
end
|
13
|
-
|
14
|
-
# Resolve unknown methods by using RubyLess in the current compilation context (the
|
15
|
-
# translate method in RubyLess will call 'safe_method_type' in this module).
|
16
|
-
def r_unknown
|
17
|
-
rubyless_render(@method, @params)
|
18
|
-
rescue ::RubyLess::NoMethodError => err
|
19
|
-
parser_error("#{err.error_message} <span class='type'>#{err.method_with_arguments}</span>", err.receiver_with_class)
|
20
|
-
rescue ::RubyLess::Error => err
|
21
|
-
parser_error(err.message)
|
22
|
-
end
|
23
|
-
|
24
|
-
# Print documentation on the current node type.
|
25
|
-
def r_m
|
26
|
-
if @params[:helper] == 'true'
|
27
|
-
klass = helper.class
|
28
|
-
else
|
29
|
-
klass = node.klass
|
30
|
-
end
|
31
|
-
|
32
|
-
out "<div class='rubyless-m'><h3>Documentation for <b>#{klass}</b></h3>"
|
33
|
-
out "<ul>"
|
34
|
-
::RubyLess::SafeClass.safe_methods_for(klass).each do |signature, opts|
|
35
|
-
opts = opts.dup
|
36
|
-
opts.delete(:method)
|
37
|
-
if opts.keys == [:class]
|
38
|
-
opts = opts[:class]
|
39
|
-
end
|
40
|
-
out "<li>#{signature.inspect} => #{opts.inspect}</li>"
|
41
|
-
end
|
42
|
-
out "</ul></div>"
|
43
|
-
end
|
44
|
-
|
45
|
-
# TEMPORARY METHOD DURING HACKING...
|
46
|
-
def r_erb
|
47
|
-
"<pre><%= @erb.gsub('<','<').gsub('>','>') %></pre>"
|
48
|
-
end
|
49
|
-
|
50
|
-
def rubyless_render(method, params)
|
51
|
-
rubyless_expand(::RubyLess.translate(method_with_arguments(method, params), self))
|
52
|
-
end
|
53
|
-
|
54
|
-
def rubyless_attr(val)
|
55
|
-
::RubyLess.translate_string(val, self)
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
def get_method_type(signature, added_options = false)
|
60
|
-
if type = node_context_from_signature(signature)
|
61
|
-
# Resolve @page, @node
|
62
|
-
type
|
63
|
-
elsif type = safe_method_from(helper, signature)
|
64
|
-
# Resolve template helper methods
|
65
|
-
type
|
66
|
-
elsif helper.respond_to?(:helpers) && type = safe_method_from(helper.helpers, signature)
|
67
|
-
# Resolve by looking at the included helpers
|
68
|
-
type
|
69
|
-
elsif node && node.klass.kind_of?(Class) && type = safe_method_from(node.klass, signature)
|
70
|
-
# Resolve node context methods (xxx.foo, xxx.bar)
|
71
|
-
type.merge(:method => "#{node.name}.#{type[:method]}")
|
72
|
-
elsif node && !added_options
|
73
|
-
# Try prepending current node before arguments: link("foo") becomse link(var1, "foo")
|
74
|
-
signature_with_node = signature.dup
|
75
|
-
signature_with_node.insert(1, node.klass)
|
76
|
-
if type = get_method_type(signature_with_node, added_options = true)
|
77
|
-
type = type.merge(:prepend_args => ::RubyLess::TypedString.new(node.name, :class => node.klass))
|
78
|
-
type
|
79
|
-
else
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
else
|
83
|
-
nil
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def method_with_arguments(method, params)
|
88
|
-
hash_arguments = {}
|
89
|
-
arguments = []
|
90
|
-
keys = params.keys.map {|k| k.to_s}
|
91
|
-
keys.sort.each do |k|
|
92
|
-
if k.to_s =~ /\A_/
|
93
|
-
arguments << params[k.to_sym]
|
94
|
-
else
|
95
|
-
hash_arguments[k.to_s] = params[k.to_sym]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
arguments += [hash_arguments] if hash_arguments != {}
|
100
|
-
if arguments != [] && method[-1..-1] =~ /\w/
|
101
|
-
"#{method}(#{arguments.inspect[1..-2]})"
|
102
|
-
else
|
103
|
-
method
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def rubyless_expand(res)
|
108
|
-
if res.klass == String && @blocks.map {|b| b.kind_of?(String) ? nil : b.method}.compact.empty?
|
109
|
-
out "<%= #{res} %>"
|
110
|
-
elsif res.could_be_nil?
|
111
|
-
out "<% if #{var} = #{res} -%>"
|
112
|
-
out @markup.wrap(expand_with_node(var, res.klass))
|
113
|
-
out "<% end -%>"
|
114
|
-
else
|
115
|
-
out "<% #{var} = #{res} -%>"
|
116
|
-
out @markup.wrap(expand_with_node(var, res.klass))
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# This is used to resolve '@node' as NodeContext with class Node, '@page' as first NodeContext
|
121
|
-
# of type Page, etc.
|
122
|
-
def node_context_from_signature(signature)
|
123
|
-
return nil unless signature.size == 1
|
124
|
-
ivar = signature.first
|
125
|
-
return nil unless ivar[0..0] == '@'
|
126
|
-
begin
|
127
|
-
klass = Module.const_get(ivar[1..-1].capitalize)
|
128
|
-
context = node(klass)
|
129
|
-
rescue NameError
|
130
|
-
return nil
|
131
|
-
end
|
132
|
-
{:class => context.klass, :method => context.name}
|
133
|
-
end
|
134
|
-
|
135
|
-
def safe_method_from(context, signature)
|
136
|
-
if context.respond_to?(:safe_method_type)
|
137
|
-
context.safe_method_type(signature)
|
138
|
-
else
|
139
|
-
::RubyLess::SafeClass.safe_method_type_for(context, signature)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
end # RubyLess
|
144
|
-
end # Process
|
145
|
-
end # Zafu
|