masterview 0.0.2
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/CHANGELOG +1 -0
- data/MIT-LICENSE +20 -0
- data/README +574 -0
- data/Rakefile +149 -0
- data/generators/masterview/USAGE +32 -0
- data/generators/masterview/masterview_generator.rb +277 -0
- data/generators/masterview/templates/controller.rb +50 -0
- data/generators/masterview/templates/fields_scaffold.rhtml +1 -0
- data/generators/masterview/templates/form_scaffold.rhtml +3 -0
- data/generators/masterview/templates/functional_test.rb +83 -0
- data/generators/masterview/templates/helper.rb +2 -0
- data/generators/masterview/templates/layout.rhtml +11 -0
- data/generators/masterview/templates/list_head_scaffold.rhtml +4 -0
- data/generators/masterview/templates/list_line_scaffold.rhtml +6 -0
- data/generators/masterview/templates/masterview.rhtml +182 -0
- data/generators/masterview/templates/mvpreview.js +31 -0
- data/generators/masterview/templates/semantic.cache +84 -0
- data/generators/masterview/templates/show_scaffold.rhtml +3 -0
- data/generators/masterview/templates/style.css +61 -0
- data/generators/masterview_gem_plugin/masterview_gem_plugin_generator.rb +21 -0
- data/generators/masterview_gem_plugin/templates/init.rb +43 -0
- data/init.rb +43 -0
- data/lib/masterview/directive_base.rb +163 -0
- data/lib/masterview/directive_helpers.rb +176 -0
- data/lib/masterview/directives/block.rb +30 -0
- data/lib/masterview/directives/content.rb +10 -0
- data/lib/masterview/directives/else.rb +25 -0
- data/lib/masterview/directives/elsif.rb +26 -0
- data/lib/masterview/directives/form.rb +19 -0
- data/lib/masterview/directives/global_inline_erb.rb +39 -0
- data/lib/masterview/directives/hidden_field.rb +31 -0
- data/lib/masterview/directives/if.rb +24 -0
- data/lib/masterview/directives/insert_generated_comment.rb +30 -0
- data/lib/masterview/directives/javascript_include.rb +15 -0
- data/lib/masterview/directives/link_to.rb +17 -0
- data/lib/masterview/directives/link_to_if.rb +21 -0
- data/lib/masterview/directives/link_to_remote.rb +17 -0
- data/lib/masterview/directives/password_field.rb +33 -0
- data/lib/masterview/directives/preview.rb +10 -0
- data/lib/masterview/directives/replace.rb +18 -0
- data/lib/masterview/directives/stylesheet_link.rb +14 -0
- data/lib/masterview/directives/submit.rb +14 -0
- data/lib/masterview/directives/testfilter.rb +55 -0
- data/lib/masterview/directives/text_area.rb +34 -0
- data/lib/masterview/directives/text_field.rb +33 -0
- data/lib/masterview/extras/rails_init.rb +67 -0
- data/lib/masterview/extras/watcher.rb +30 -0
- data/lib/masterview/masterview_version.rb +9 -0
- data/lib/masterview/parser.rb +585 -0
- data/lib/masterview/plugin_load_tracking.rb +41 -0
- data/lib/masterview/runtime_helpers.rb +9 -0
- data/lib/masterview/string_extensions.rb +15 -0
- data/lib/masterview.rb +130 -0
- data/test/block_test.rb +47 -0
- data/test/content_test.rb +26 -0
- data/test/else_test.rb +31 -0
- data/test/elsif_test.rb +31 -0
- data/test/example_test.rb +11 -0
- data/test/filter_helpers_test.rb +142 -0
- data/test/form_test.rb +66 -0
- data/test/global_inline_erb_test.rb +30 -0
- data/test/hidden_field_test.rb +62 -0
- data/test/if_test.rb +23 -0
- data/test/javascript_include_test.rb +26 -0
- data/test/link_to_if_test.rb +27 -0
- data/test/link_to_test.rb +52 -0
- data/test/parser_test.rb +166 -0
- data/test/password_field_test.rb +89 -0
- data/test/replace_test.rb +27 -0
- data/test/run_parser_test.rb +27 -0
- data/test/stylesheet_link_test.rb +26 -0
- data/test/submit_test.rb +54 -0
- data/test/template_file_watcher_test.rb +50 -0
- data/test/template_test.rb +181 -0
- data/test/test_helper.rb +24 -0
- data/test/text_area_test.rb +81 -0
- data/test/text_field_test.rb +89 -0
- metadata +136 -0
@@ -0,0 +1,176 @@
|
|
1
|
+
module MasterView
|
2
|
+
|
3
|
+
module DirectiveHelpers
|
4
|
+
CRLF = "\r\n"
|
5
|
+
ERB_START = '<% '
|
6
|
+
ERB_EVAL = '<%= '
|
7
|
+
ERB_END = ' %>'
|
8
|
+
|
9
|
+
#convenience constants defined to allow priority to directives
|
10
|
+
#higher priority (lower value) will be executed first in chain
|
11
|
+
module DirectivePriorities
|
12
|
+
Highest = 0
|
13
|
+
High = 0x3FFFFFFF/4
|
14
|
+
MediumHigh = 0x3FFFFFFF/3
|
15
|
+
Medium = 0x3FFFFFFF/2
|
16
|
+
MediumLow = (0x3FFFFFFF/3)*2
|
17
|
+
Low = (0x3FFFFFFF/4)*3
|
18
|
+
Lowest = 0x3FFFFFFF
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# find the last string that fully matches exactly the
|
23
|
+
# parent tags content string array
|
24
|
+
# It looks for something that has been output as a unit in
|
25
|
+
# the array not a substring
|
26
|
+
# returns the ref to the string which you can operate on
|
27
|
+
# using replace
|
28
|
+
def find_last_in_parent(tag, full_string)
|
29
|
+
ret = nil
|
30
|
+
parent = tag.parent
|
31
|
+
unless parent.nil?
|
32
|
+
parent.content.reverse.each do |str|
|
33
|
+
if str == full_string
|
34
|
+
ret = str
|
35
|
+
break
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
ret
|
40
|
+
end
|
41
|
+
|
42
|
+
# set the last occurence to empty string
|
43
|
+
# returns true if found and set to empty string
|
44
|
+
def delete_last_in_parent(tag, full_string)
|
45
|
+
str = find_last_in_parent(tag, full_string)
|
46
|
+
found = !str.nil?
|
47
|
+
str.replace('') if found
|
48
|
+
found
|
49
|
+
end
|
50
|
+
|
51
|
+
# find a hash value from inside a simple str containing a hash
|
52
|
+
# non-evaling, looks for a :key => 'foo/bar' returning foo/bar string
|
53
|
+
def find_string_val_in_string_hash(str, key_or_sym)
|
54
|
+
key = key_or_sym.to_s
|
55
|
+
m = str.match( Regexp.new( Regexp.escape(key)+"\s*=>\s*'([^']*)'" ) ) #try single quote
|
56
|
+
m = str.match( Regexp.new( Regexp.escape(key)+"\s*=>\s*\"([^\"]*)\"" ) ) if m.nil? #try double quote
|
57
|
+
return nil if m.nil?
|
58
|
+
m[1]
|
59
|
+
end
|
60
|
+
|
61
|
+
#returns an array of args by parsing and evaling the str value passed in
|
62
|
+
#uses evaling, so can't have any variables only simple strings, numbers, booleans
|
63
|
+
def parse_eval_into_array(value)
|
64
|
+
return [] if value.nil? || value.empty?
|
65
|
+
val = value.strip
|
66
|
+
args = []
|
67
|
+
until val.empty?
|
68
|
+
if val =~ /^[:'"%\[{&*]/ #starts with quote or ruby lang char
|
69
|
+
v = nil
|
70
|
+
val = '{'+val+'}' if val =~ /^:/ #starts with colon, assume hash so wrap with brackets
|
71
|
+
eval 'v = '+ val #rest is all evaled
|
72
|
+
if v.is_a? Array
|
73
|
+
args += v
|
74
|
+
else
|
75
|
+
args << v
|
76
|
+
end
|
77
|
+
break
|
78
|
+
else
|
79
|
+
unquoted_string = val.slice!( /^[^,]+/ ) #pull off everything up to a comma
|
80
|
+
unquoted_string.strip!
|
81
|
+
args.push unquoted_string
|
82
|
+
val.slice!( /^,/ ) #strip off comma if exists
|
83
|
+
val.strip!
|
84
|
+
end
|
85
|
+
end
|
86
|
+
args
|
87
|
+
end
|
88
|
+
|
89
|
+
#returns a hash, for values that are not already part of hash it adds them using default_key
|
90
|
+
#uses evaling so it cannot have any variables or non-simple types
|
91
|
+
def parse_eval_into_hash(value, default_key)
|
92
|
+
h = {}
|
93
|
+
a = parse_eval_into_array(value)
|
94
|
+
a.each do |v|
|
95
|
+
if v.is_a?(Hash)
|
96
|
+
h.merge!(v)
|
97
|
+
else #it adds any additional non-hash args using default key, if key,val exists, it changes to array and appends
|
98
|
+
prev = h[default_key]
|
99
|
+
if prev.nil? #nil just add it
|
100
|
+
h[default_key] = v
|
101
|
+
elsif prev.is_a?(Array) #was array, concat
|
102
|
+
h[default_key] = prev+v
|
103
|
+
else #anything else, make it into array
|
104
|
+
h[default_key] = [prev, v]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
h
|
109
|
+
end
|
110
|
+
|
111
|
+
#parse into array of strings, containing the various arguments without evaling
|
112
|
+
#looks for %q{}, %q[], hash, array, function call using (), values deliminated by commas,
|
113
|
+
#it does not handle embedded quotes yet
|
114
|
+
def parse(str)
|
115
|
+
return [] if str.nil? || str.strip.empty?
|
116
|
+
s = str.strip
|
117
|
+
args = []
|
118
|
+
s.scan( /(%q"[^"]*"|%q\{[^}]*\}|%q\[[^\]]*\]|\{?\s*\S+\s*=>[^{}]+\}?|\[[^\]]*\]|[\w\.@]+\s*\([^\)]*\)|'[^']*'|[^,]+)\s*,?\s*/ ).flatten
|
119
|
+
end
|
120
|
+
|
121
|
+
#remove any strings that were prepended to the hashes, typically these are overridden by other values, so
|
122
|
+
# we need to strip them off leaving only the hashes, returns a string with only hashes
|
123
|
+
def remove_prepended_strings(full_string)
|
124
|
+
return full_string if full_string.nil? || full_string.strip.empty?
|
125
|
+
hashes = full_string.scan( /(\{?)\s*(\S+\s*=>.*)/ ).flatten
|
126
|
+
hashes.join.strip
|
127
|
+
end
|
128
|
+
|
129
|
+
#merge hash_to_merge values into the hash contained in the full_string, hash_arg is zero based index of which
|
130
|
+
#hash this needes to be merged to if there are multiple ones.
|
131
|
+
def merge_into_embedded_hash(full_string, hash_arg, hash_to_merge)
|
132
|
+
return full_string if hash_to_merge.empty?
|
133
|
+
full_string ||= ""
|
134
|
+
sorted_hash_to_merge = hash_to_merge.sort { |a,b| a.to_s <=> b.to_s } #sort, remember the keys might be symbols so use to_s
|
135
|
+
str_to_merge = sorted_hash_to_merge.collect{ |h,v| "#{h.inspect} => #{v.inspect}" }.join(', ')
|
136
|
+
|
137
|
+
hashes = full_string.scan( /(\{?[^{}]+=>[^{}]+\}?)\s*,?\s*/ ).flatten
|
138
|
+
hash_str = hashes[hash_arg] #be careful to use methods to update string in place or else put back in hash
|
139
|
+
|
140
|
+
if hash_str.nil?
|
141
|
+
hashes.each do |v| #make sure each prior hash has brackets, since we are adding a hash
|
142
|
+
unless v.index '}'
|
143
|
+
v.insert(0, '{')
|
144
|
+
v.insert(-1, '}')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
hashes[hash_arg] = hash_str = ""
|
148
|
+
end
|
149
|
+
|
150
|
+
closing_brack = hash_str.index '}'
|
151
|
+
if closing_brack
|
152
|
+
hash_str.insert(closing_brack, ', '+str_to_merge)
|
153
|
+
else
|
154
|
+
hash_str << ', ' unless hash_str.empty?
|
155
|
+
hash_str << str_to_merge
|
156
|
+
end
|
157
|
+
|
158
|
+
hashes.join(', ')
|
159
|
+
end
|
160
|
+
|
161
|
+
#return attributes with lowercase keys
|
162
|
+
def lowercase_attribute_keys(attributes)
|
163
|
+
lcattrs = {}
|
164
|
+
attributes.each { |k,v| lcattrs[k.downcase] = v }
|
165
|
+
lcattrs
|
166
|
+
end
|
167
|
+
|
168
|
+
#return attributes with lowercase keys and values
|
169
|
+
def lowercase_attribute_keys_and_values(attributes)
|
170
|
+
lcattrs = {}
|
171
|
+
attributes.each { |k,v| lcattrs[k.downcase] = v.downcase }
|
172
|
+
lcattrs
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#outputs a block around the text tags, if left bracket count is higher than right
|
5
|
+
#assume that the end is a right bracket otherwise use end
|
6
|
+
class Block < MasterView::DirectiveBase
|
7
|
+
def priority
|
8
|
+
DirectivePriorities::MediumHigh
|
9
|
+
end
|
10
|
+
|
11
|
+
def stag(directive_call_stack)
|
12
|
+
count_left_brackets = attr_value.scan( /\{/ ).size
|
13
|
+
count_right_brackets = attr_value.scan( /\}/ ).size
|
14
|
+
@end_block = (count_left_brackets > count_right_brackets) ? '}' : 'end'
|
15
|
+
|
16
|
+
ret = []
|
17
|
+
ret << erb(attr_value)
|
18
|
+
ret << directive_call_stack.render
|
19
|
+
end
|
20
|
+
|
21
|
+
def etag(directive_call_stack)
|
22
|
+
ret = []
|
23
|
+
ret << directive_call_stack.render
|
24
|
+
ret << erb(@end_block)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
#outputs an else/end block around the text tags removing previous end tag (from if/elsif)
|
4
|
+
class Else < MasterView::DirectiveBase
|
5
|
+
def priority
|
6
|
+
DirectivePriorities::High
|
7
|
+
end
|
8
|
+
|
9
|
+
def stag(directive_call_stack)
|
10
|
+
tag = @directive_call_stack.context[:tag]
|
11
|
+
delete_last_in_parent(tag, erb('end') )
|
12
|
+
ret = []
|
13
|
+
ret << erb('else')
|
14
|
+
ret << directive_call_stack.render
|
15
|
+
end
|
16
|
+
|
17
|
+
def etag(directive_call_stack)
|
18
|
+
ret = []
|
19
|
+
ret << directive_call_stack.render
|
20
|
+
ret << erb('end')
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#outputs an elsif/end block around the text tags and remove previous end (from if)
|
5
|
+
class Elsif < MasterView::DirectiveBase
|
6
|
+
def priority
|
7
|
+
DirectivePriorities::High
|
8
|
+
end
|
9
|
+
|
10
|
+
def stag(directive_call_stack)
|
11
|
+
tag = @directive_call_stack.context[:tag]
|
12
|
+
delete_last_in_parent(tag, erb('end') )
|
13
|
+
ret = []
|
14
|
+
ret << erb('elsif '+attr_value)
|
15
|
+
ret << directive_call_stack.render
|
16
|
+
end
|
17
|
+
|
18
|
+
def etag(directive_call_stack)
|
19
|
+
ret = []
|
20
|
+
ret << directive_call_stack.render
|
21
|
+
ret << erb('end')
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
# creates start_form_tag and end_form_tag from values in form
|
5
|
+
class Form < MasterView::DirectiveBase
|
6
|
+
def stag(directive_call_stack)
|
7
|
+
options = {}
|
8
|
+
options[:multipart] = true if attr_lckv_matches('enctype', 'multipart/form-data')
|
9
|
+
options[:method] = 'get' if attr_lckv_matches('method', 'get')
|
10
|
+
merge_hash_attr_value!(1, options)
|
11
|
+
erb_content('form_tag ' + attr_value)
|
12
|
+
end
|
13
|
+
|
14
|
+
def etag(directive_call_stack)
|
15
|
+
erb_content('end_form_tag')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#outputs a block around the text tags, if left bracket count is higher than right
|
5
|
+
#assume that the end is a right bracket otherwise use end
|
6
|
+
class Global_inline_erb < MasterView::DirectiveBase
|
7
|
+
def initialize(attribute_value = nil)
|
8
|
+
super(attribute_value)
|
9
|
+
end
|
10
|
+
|
11
|
+
def priority
|
12
|
+
DirectivePriorities::Low
|
13
|
+
end
|
14
|
+
|
15
|
+
def global_directive?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def stag(dcs)
|
20
|
+
attrs.each do |key, value|
|
21
|
+
replace_with_erb!( value )
|
22
|
+
end
|
23
|
+
dcs.render
|
24
|
+
end
|
25
|
+
|
26
|
+
def characters(dcs)
|
27
|
+
replace_with_erb!( data )
|
28
|
+
dcs.render
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def replace_with_erb!(value)
|
34
|
+
subs = value.gsub!( MasterView::InlineErbSubstitutionRegex, '<%\1%>' )
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
class Hidden_field < MasterView::DirectiveBase
|
5
|
+
def stag(dcs)
|
6
|
+
#eat
|
7
|
+
end
|
8
|
+
|
9
|
+
def etag(dcs)
|
10
|
+
args = parse_attr_value
|
11
|
+
obj = args[0]
|
12
|
+
method = args[1]
|
13
|
+
|
14
|
+
obj = quote(obj) unless obj =~ /^:|'|"/
|
15
|
+
method = quote(method) unless method =~ /^:|'|"/
|
16
|
+
|
17
|
+
options = {}
|
18
|
+
options.merge! common_html_options(attrs_lck)
|
19
|
+
remove_strings_from_attr_value!
|
20
|
+
merge_hash_attr_value!(0, options)
|
21
|
+
|
22
|
+
a = []
|
23
|
+
a << 'hidden_field '+ obj
|
24
|
+
a << method
|
25
|
+
a << attr_value unless attr_value.strip.empty?
|
26
|
+
erb_content(a.join(', '))
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#outputs an if/end block around the text tags
|
5
|
+
class If < MasterView::DirectiveBase
|
6
|
+
def priority
|
7
|
+
DirectivePriorities::High
|
8
|
+
end
|
9
|
+
|
10
|
+
def stag(directive_call_stack)
|
11
|
+
ret = []
|
12
|
+
ret << erb('if '+attr_value)
|
13
|
+
ret << directive_call_stack.render
|
14
|
+
end
|
15
|
+
|
16
|
+
def etag(directive_call_stack)
|
17
|
+
ret = []
|
18
|
+
ret << directive_call_stack.render
|
19
|
+
ret << erb('end')
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
# Inserts a comment into the file that indicates that this file was generated
|
5
|
+
# and should not be edited, else changes could be lost. It includes the path to
|
6
|
+
# the original file that should be edited instead
|
7
|
+
class Insert_generated_comment < MasterView::DirectiveBase
|
8
|
+
Generated_comment_text = <<-END
|
9
|
+
# WARNING - This file was generated by MasterView plugin.
|
10
|
+
# Do not edit this file otherwise you may lose your changes
|
11
|
+
# when this file is re-generated.
|
12
|
+
#
|
13
|
+
# To make changes edit the MasterView file which is located at:
|
14
|
+
END
|
15
|
+
|
16
|
+
def priority
|
17
|
+
DirectivePriorities::Lowest
|
18
|
+
end
|
19
|
+
|
20
|
+
def stag(directive_call_stack)
|
21
|
+
comment = "\n<% \n" + Generated_comment_text + "# "+ attr_value + "\n%>"
|
22
|
+
|
23
|
+
ret = []
|
24
|
+
ret << directive_call_stack.render
|
25
|
+
ret << comment
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#creates a link_to
|
5
|
+
class Javascript_include < MasterView::DirectiveBase
|
6
|
+
def stag(dcs)
|
7
|
+
end
|
8
|
+
|
9
|
+
def etag(dcs)
|
10
|
+
val = attr_value.starts_with?(':') ? attr_value : quote(attr_value)
|
11
|
+
erb_content('javascript_include_tag ' + val)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#creates a link_to
|
5
|
+
class Link_to < MasterView::DirectiveBase
|
6
|
+
def stag(dcs)
|
7
|
+
end
|
8
|
+
|
9
|
+
def etag(dcs)
|
10
|
+
remove_strings_from_attr_value!
|
11
|
+
prepend_to_attr_value! quote( content_str ) #prepend quoted link name
|
12
|
+
self.content=''
|
13
|
+
erb_content('link_to ' + attr_value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
class Link_to_if < MasterView::DirectiveBase
|
5
|
+
def stag(dcs)
|
6
|
+
end
|
7
|
+
|
8
|
+
def etag(dcs)
|
9
|
+
args = parse_attr_value
|
10
|
+
condition = args[0]
|
11
|
+
remove_strings_from_attr_value!
|
12
|
+
a = []
|
13
|
+
a << 'link_to_if '+condition
|
14
|
+
a << quote(content_str)
|
15
|
+
a << attr_value unless attr_value.strip.empty?
|
16
|
+
self.content=''
|
17
|
+
erb_content(a.join(', '))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#creates a link_to_remote
|
5
|
+
class Link_to_remote < MasterView::DirectiveBase
|
6
|
+
def stag(dcs)
|
7
|
+
end
|
8
|
+
|
9
|
+
def etag(dcs)
|
10
|
+
remove_strings_from_attr_value!
|
11
|
+
prepend_to_attr_value! quote( content_str ) #prepend quoted link name
|
12
|
+
self.content=''
|
13
|
+
erb_content('link_to_remote ' + attr_value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
class Password_field < MasterView::DirectiveBase
|
5
|
+
def stag(dcs)
|
6
|
+
#eat
|
7
|
+
end
|
8
|
+
|
9
|
+
def etag(dcs)
|
10
|
+
args = parse_attr_value
|
11
|
+
obj = args[0]
|
12
|
+
method = args[1]
|
13
|
+
|
14
|
+
obj = quote(obj) unless obj =~ /^:|'|"/
|
15
|
+
method = quote(method) unless method =~ /^:|'|"/
|
16
|
+
|
17
|
+
options = {}
|
18
|
+
options[:size] = attrs_lck['size'].to_i if attrs_lck['size']
|
19
|
+
options[:maxlength] = attrs_lck['maxlength'].to_i if attrs_lck['maxlength']
|
20
|
+
options.merge! common_html_options(attrs_lck)
|
21
|
+
remove_strings_from_attr_value!
|
22
|
+
merge_hash_attr_value!(0, options)
|
23
|
+
|
24
|
+
a = []
|
25
|
+
a << 'password_field '+ obj
|
26
|
+
a << method
|
27
|
+
a << attr_value unless attr_value.strip.empty?
|
28
|
+
erb_content(a.join(', '))
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
class Replace < MasterView::DirectiveBase
|
5
|
+
def priority
|
6
|
+
DirectivePriorities::MediumLow
|
7
|
+
end
|
8
|
+
|
9
|
+
def stag(directive_call_stack)
|
10
|
+
end
|
11
|
+
|
12
|
+
def etag(directive_call_stack)
|
13
|
+
self.content=''
|
14
|
+
erb_content(attr_value) unless attr_value.blank?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
class Submit < MasterView::DirectiveBase
|
5
|
+
def stag(directive_call_stack); end
|
6
|
+
|
7
|
+
def etag(directive_call_stack)
|
8
|
+
remove_strings_from_attr_value!
|
9
|
+
prepend_to_attr_value! quote( attrs_lck['value'] ) #prepend quoted submit button name
|
10
|
+
erb_content('submit_tag ' + attr_value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
class TestDirective < MasterView::DirectiveBase
|
5
|
+
def priority
|
6
|
+
DirectivePriorities::Low
|
7
|
+
end
|
8
|
+
|
9
|
+
def stag(dcs)
|
10
|
+
ret = []
|
11
|
+
ret << 'stag'
|
12
|
+
ret << dcs.render
|
13
|
+
ret << 'stagend'
|
14
|
+
end
|
15
|
+
|
16
|
+
def characters(dcs)
|
17
|
+
ret = []
|
18
|
+
ret << 'char'
|
19
|
+
ret << dcs.render
|
20
|
+
end
|
21
|
+
|
22
|
+
def comment(dcs)
|
23
|
+
ret = []
|
24
|
+
ret << 'com'
|
25
|
+
ret << dcs.render
|
26
|
+
end
|
27
|
+
|
28
|
+
def cdata(dcs)
|
29
|
+
ret = []
|
30
|
+
ret << 'cdata'
|
31
|
+
ret << dcs.render
|
32
|
+
end
|
33
|
+
|
34
|
+
def etag(dcs)
|
35
|
+
ret = []
|
36
|
+
ret << 'etag'
|
37
|
+
ret << dcs.render
|
38
|
+
ret << 'etagend'
|
39
|
+
end
|
40
|
+
|
41
|
+
def child_title_stag(dcs)
|
42
|
+
ret = []
|
43
|
+
ret << 'desctitle'
|
44
|
+
ret << dcs.render
|
45
|
+
end
|
46
|
+
|
47
|
+
def child_title_etag(dcs)
|
48
|
+
dcs.context[:tag].content = @attribute_value
|
49
|
+
ret = []
|
50
|
+
ret << dcs.render
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
class Text_area < MasterView::DirectiveBase
|
5
|
+
def stag(dcs)
|
6
|
+
#eat
|
7
|
+
end
|
8
|
+
|
9
|
+
def etag(dcs)
|
10
|
+
args = parse_attr_value
|
11
|
+
obj = args[0]
|
12
|
+
method = args[1]
|
13
|
+
|
14
|
+
obj = quote(obj) unless obj =~ /^:|'|"/
|
15
|
+
method = quote(method) unless method =~ /^:|'|"/
|
16
|
+
|
17
|
+
options = {}
|
18
|
+
options[:rows] = attrs_lck['rows'].to_i if attrs_lck['rows']
|
19
|
+
options[:cols] = attrs_lck['cols'].to_i if attrs_lck['cols']
|
20
|
+
options.merge! common_html_options(attrs_lck)
|
21
|
+
remove_strings_from_attr_value!
|
22
|
+
merge_hash_attr_value!(0, options)
|
23
|
+
|
24
|
+
a = []
|
25
|
+
a << 'text_area '+ obj
|
26
|
+
a << method
|
27
|
+
a << attr_value unless attr_value.strip.empty?
|
28
|
+
self.content=''
|
29
|
+
erb_content(a.join(', '))
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|