masterview 0.0.6 → 0.0.7
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/Rakefile +8 -5
- data/init.rb +43 -0
- data/lib/facets/AUTHORS +36 -0
- data/lib/facets/CHANGELOG +266 -0
- data/lib/facets/COPYING +403 -0
- data/lib/facets/ProjectInfo +74 -0
- data/lib/facets/README +252 -0
- data/lib/facets/core/string/blank.rb +36 -0
- data/lib/facets/core/string/indent.rb +68 -0
- data/lib/facets/core/string/starts_with.rb +24 -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 +129 -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 +71 -11
data/lib/facets/README
ADDED
@@ -0,0 +1,252 @@
|
|
1
|
+
|
2
|
+
= Ruby Facets
|
3
|
+
|
4
|
+
"ALL BASE COMMON"
|
5
|
+
|
6
|
+
|
7
|
+
== Introduction
|
8
|
+
|
9
|
+
Ruby Facets
|
10
|
+
|
11
|
+
Facets/CORE is a vast collection of methods which extend the core
|
12
|
+
capabilities of Ruby's built-in classes and modules.
|
13
|
+
|
14
|
+
This collection of extension methods is unique by virtue of its atomicity.
|
15
|
+
The methods are stored individually so that each can be required
|
16
|
+
independently. This gives developers fine-grain control over which
|
17
|
+
extra methods to bring into his or her code. The collection currently
|
18
|
+
contains over 400 methods spanning 28 classes and modules.
|
19
|
+
|
20
|
+
Facets/MORE is a collection of additioanl classes, modules and microframeworks.
|
21
|
+
|
22
|
+
The class, module and microframework additions consitute an ever growing
|
23
|
+
and improving source of reusable components. Some very nice adsitions
|
24
|
+
have recently been added, from an amazing Units system to an elegant
|
25
|
+
annotations systems. And of course there are all the more typical goodies
|
26
|
+
like Tuple, Functor and Multiton.
|
27
|
+
|
28
|
+
== Mission
|
29
|
+
|
30
|
+
Facets holds to the notion that the more we can reasonably integrate into
|
31
|
+
a common foundation directed toward general needs, the better that foundation
|
32
|
+
will be able to serve us. There are a number of advantages here:
|
33
|
+
|
34
|
+
* Better Code-reuse
|
35
|
+
* Collaborative Improvements
|
36
|
+
* Greater Name Consistency
|
37
|
+
* One-stop Shop and Installation
|
38
|
+
|
39
|
+
|
40
|
+
== Status
|
41
|
+
|
42
|
+
The current status is quite good. While various parts are still considered
|
43
|
+
Beta, everything is relatively usable.
|
44
|
+
|
45
|
+
|
46
|
+
== Installation
|
47
|
+
|
48
|
+
|
49
|
+
The easiest way to install is via RubyGems. On the command line enter:
|
50
|
+
|
51
|
+
> gem install facets
|
52
|
+
|
53
|
+
To manually install, unpack the .tbz (.tar.bz2) package and use the included
|
54
|
+
setup.rb script. For example:
|
55
|
+
|
56
|
+
> tar -xvzf facets,YYYY-MM-DD.tbz
|
57
|
+
> cd facets,YYYY-MM-DD
|
58
|
+
> sudo ruby setup.rb
|
59
|
+
|
60
|
+
|
61
|
+
== Usage
|
62
|
+
|
63
|
+
For detailed usage of any given method or module please refer to the
|
64
|
+
API RDocs. Most are well documented.
|
65
|
+
|
66
|
+
To use a single facet you simply require the method by name, for example:
|
67
|
+
|
68
|
+
require 'facet/time/stamp'
|
69
|
+
|
70
|
+
Techinally this requires a redirection file to the core method itself.
|
71
|
+
You can bypass the redirection:
|
72
|
+
|
73
|
+
require 'facets/core/time/stamp'
|
74
|
+
|
75
|
+
Although not at all neccessary, if you are using more then a few facets
|
76
|
+
it is recommended that before requiring any of them you first require
|
77
|
+
the main facility.
|
78
|
+
|
79
|
+
require 'facets'
|
80
|
+
|
81
|
+
This loads all the core facets considered "base" (a couple dozen basic methods)
|
82
|
+
and add the facets library directories to the end of Ruby's load path. This
|
83
|
+
allows you to require facets without the 'facet/...' prefix. Eg.
|
84
|
+
|
85
|
+
require 'string/blank'
|
86
|
+
|
87
|
+
A handful of extension sets are also available. For example,
|
88
|
+
|
89
|
+
require 'facet/string_as_array'
|
90
|
+
|
91
|
+
adds some methods to Array that make it behave a little more like
|
92
|
+
an array of characters. Other useful sets include, 'random' which
|
93
|
+
loads every facet method related to randomness and 'inflect' which
|
94
|
+
loads a number of methods for manipulating strings in high-level
|
95
|
+
ways, like #camelize and #pluralize.
|
96
|
+
|
97
|
+
Using a module, class or microframework is essentially the same.
|
98
|
+
You can use the redirection path. Eg.
|
99
|
+
|
100
|
+
require 'facet/basicobject'
|
101
|
+
|
102
|
+
Or do so directly.
|
103
|
+
|
104
|
+
require 'facets/more/basicobject'
|
105
|
+
|
106
|
+
Again, if you load the main facility, you can eliminate the need for the 'facet/' prefix.
|
107
|
+
|
108
|
+
require 'facets'
|
109
|
+
require 'basicobject'
|
110
|
+
|
111
|
+
Understand that on the off chance that anoth library you are using has the same name as
|
112
|
+
one of Facets' everything will still work fine. You will not be able to use the
|
113
|
+
prefixless shorcut to require the facet.
|
114
|
+
|
115
|
+
For details pertaining to the functionality of each feature, please see the API Docs.
|
116
|
+
|
117
|
+
|
118
|
+
== Notes
|
119
|
+
|
120
|
+
=== Directories
|
121
|
+
|
122
|
+
There are presently three two subdirs in Facets: 'core', which stores
|
123
|
+
the method extensions and 'more' which store the modules, classes and
|
124
|
+
micorframeworks.
|
125
|
+
|
126
|
+
The layout of Facets' core method files is straightfoward and well organized.
|
127
|
+
All individual methods are stored in subdirectories under their effected
|
128
|
+
downcased class' or module's name.
|
129
|
+
|
130
|
+
'<class|module>/<method-name>'
|
131
|
+
|
132
|
+
Class method are stored in the same manner but under a 'self' subdirectory.
|
133
|
+
|
134
|
+
'core/<class|module>/self/<method-name>'
|
135
|
+
|
136
|
+
=== Method File Names
|
137
|
+
|
138
|
+
Operators are stored in the file system using english names. For instance for
|
139
|
+
Proc#* is 'proc/op_mul'.
|
140
|
+
|
141
|
+
For reference, here is the chart.
|
142
|
+
|
143
|
+
+@ => op_plus_self
|
144
|
+
-@ => op_minus_self
|
145
|
+
+ => op_plus
|
146
|
+
- => op_minus
|
147
|
+
** => op_pow
|
148
|
+
* => op_mul
|
149
|
+
/ => op_div
|
150
|
+
% => op_mod
|
151
|
+
~ => op_tilde
|
152
|
+
<=> => op_cmp
|
153
|
+
<< => op_lshift
|
154
|
+
>> => op_rshift
|
155
|
+
< => op_lt
|
156
|
+
> => op_gt
|
157
|
+
=== => op_case_eq
|
158
|
+
== => op_equal
|
159
|
+
=~ => op_apply
|
160
|
+
<= => op_lt_eq
|
161
|
+
>= => op_gt_eq
|
162
|
+
| => op_or
|
163
|
+
& => op_and
|
164
|
+
^ => op_xor
|
165
|
+
[]= => op_store
|
166
|
+
[] => op_fetch
|
167
|
+
|
168
|
+
Facets simply takes the '*' and translates it into a string acceptable
|
169
|
+
to all file systems. Also, if a method ends in '=', '?' or '!' it is
|
170
|
+
simply removed.
|
171
|
+
|
172
|
+
|
173
|
+
== Contribute
|
174
|
+
|
175
|
+
This project thrives on contribution.
|
176
|
+
|
177
|
+
If you have any extension methods, classes, modules or microframeworks
|
178
|
+
that you think have general applicability and would like to see them
|
179
|
+
included in this project, don't hesitiate to submit. There's a very good
|
180
|
+
chance it will be included. Also, if you have better versions of any thing
|
181
|
+
already included or simply have a patch, they too are more than welcome.
|
182
|
+
We want Ruby Facets to be of the highest quality.
|
183
|
+
|
184
|
+
|
185
|
+
== Authorship
|
186
|
+
|
187
|
+
This collection was put together by, and largely written by Thomas Sawyer
|
188
|
+
(aka Trans Onoma). He can be reached via email at transfire at gmail.com.
|
189
|
+
|
190
|
+
Some parts of this collection were written and/or inspired by other
|
191
|
+
persons. Fortunately nearly all were copyrighted under the same open
|
192
|
+
license, the Ruby License. In the few excpetions I have included the
|
193
|
+
copyright notice with the source code.
|
194
|
+
|
195
|
+
Any code file not specifically labelled shall fall under the Ruby License.
|
196
|
+
|
197
|
+
In all cases, I have made every effort to give credit where credit is due. You will find these copyrights, thanks and acknowledgements embedded in the source code, and an unobtrusive
|
198
|
+
"Author(s)" section is given in the RDocs.
|
199
|
+
|
200
|
+
Main Developers include:
|
201
|
+
|
202
|
+
* Thomas Sawyer
|
203
|
+
* George Moschovitis
|
204
|
+
* Peter Vanbroekhoven
|
205
|
+
* Florian Gross
|
206
|
+
|
207
|
+
See the AUTHORS file for a list of all other contributing Rubyists.
|
208
|
+
|
209
|
+
If anyone is missing from the list, please let me know and
|
210
|
+
I will correct right away. Thanks.
|
211
|
+
|
212
|
+
|
213
|
+
== License
|
214
|
+
|
215
|
+
In so far as it matters, the collection PER COLLECTION is licensed
|
216
|
+
as follows:
|
217
|
+
|
218
|
+
Ruby Facets
|
219
|
+
Copyright (c) 2004-2006 Thomas Sawyer
|
220
|
+
Ruby License
|
221
|
+
|
222
|
+
The Ruby license is a dual license that also provides for use of the GPL.
|
223
|
+
A copy of both licenses accompany this document (see COPYING).
|
224
|
+
|
225
|
+
Credit and Copyrights for particular borrowed code segments are
|
226
|
+
given in their respective source. All licenses are either compatible
|
227
|
+
with the Ruby lincense (Ruby or GPL) or the original author has given
|
228
|
+
permission for inclusion of their code under this lincense.</p>
|
229
|
+
|
230
|
+
Any code file not specifically labeled shall fall under the Ruby License.
|
231
|
+
|
232
|
+
|
233
|
+
== Pitch
|
234
|
+
|
235
|
+
ALL YOUR BASE ARE BELONG TO RUBY
|
236
|
+
|
237
|
+
|
238
|
+
----
|
239
|
+
|
240
|
+
[1] A lot of mental anguish went into finding this good project name Ruby Facets.
|
241
|
+
Of course, in the end only one name can take the honor. Other good names
|
242
|
+
which were considered: Calibre, Florida and California, Warchest w/ Atomix,
|
243
|
+
Downs & Ace, Trix & Atomx and even Pillbox & Pills (a _why suggestion).
|
244
|
+
Then the names that almost won out and were used for a good while:
|
245
|
+
Nano Methods and Mega Modules --great names but a little to "fad".
|
246
|
+
Finally let's not forget even older "working" titles that were used
|
247
|
+
along the way: Raspberry, ABC, Succ and the very original Tomslib.
|
248
|
+
|
249
|
+
|
250
|
+
# Copyright (c)2006 Thomas Sawyer
|
251
|
+
# facets.rubyforge.com
|
252
|
+
# (ruby-lang.org) Do you Ruby?
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
class String
|
3
|
+
|
4
|
+
# Is this string just whitespace?
|
5
|
+
#
|
6
|
+
# "abc".blank? #=> false
|
7
|
+
# " ".blank? #=> true
|
8
|
+
#
|
9
|
+
def blank?
|
10
|
+
self !~ /\S/
|
11
|
+
end
|
12
|
+
alias_method :whitespace?, :blank?
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# _____ _
|
18
|
+
# |_ _|__ ___| |_
|
19
|
+
# | |/ _ \/ __| __|
|
20
|
+
# | | __/\__ \ |_
|
21
|
+
# |_|\___||___/\__|
|
22
|
+
#
|
23
|
+
=begin test
|
24
|
+
|
25
|
+
require 'test/unit'
|
26
|
+
|
27
|
+
class TCString < Test::Unit::TestCase
|
28
|
+
|
29
|
+
def test_blank?
|
30
|
+
assert( ! "xyz".blank? )
|
31
|
+
assert( " ".blank? )
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
=end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
class String
|
3
|
+
|
4
|
+
# Aligns each line n spaces.
|
5
|
+
# (This used to be #taballto.)
|
6
|
+
#
|
7
|
+
def tab(n)
|
8
|
+
gsub(/^ */, ' ' * n)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Preserves relative tabbing.
|
12
|
+
# The first non-empty line ends up with n spaces before nonspace.
|
13
|
+
#
|
14
|
+
def tabto(n)
|
15
|
+
if self =~ /^( *)\S/
|
16
|
+
indent(n - $1.length)
|
17
|
+
else
|
18
|
+
self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Indent left or right by n spaces.
|
23
|
+
# (This used to be called #tab and aliased as #indent.)
|
24
|
+
#
|
25
|
+
def indent(n)
|
26
|
+
if n >= 0
|
27
|
+
gsub(/^/, ' ' * n)
|
28
|
+
else
|
29
|
+
gsub(/^ {0,#{-n}}/, "")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# _____ _
|
37
|
+
# |_ _|__ ___| |_
|
38
|
+
# | |/ _ \/ __| __|
|
39
|
+
# | | __/\__ \ |_
|
40
|
+
# |_|\___||___/\__|
|
41
|
+
#
|
42
|
+
=begin test
|
43
|
+
|
44
|
+
require 'test/unit'
|
45
|
+
|
46
|
+
class TCString < Test::Unit::TestCase
|
47
|
+
|
48
|
+
def test_tab
|
49
|
+
a = "xyz".tab(4)
|
50
|
+
assert_equal( ' ', a[0..3] )
|
51
|
+
# Need to expand on this
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_tabto
|
55
|
+
a = "xyz".tabto(4)
|
56
|
+
assert_equal( ' ', a[0..3] )
|
57
|
+
# Need to expand on this
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_indent
|
61
|
+
a = "xyz".indent(4)
|
62
|
+
assert_equal( ' ', a[0..3] )
|
63
|
+
# Need to expand on this
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
=end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#--
|
2
|
+
# Credit goes to Lucas Carlson and Blaine Cook.
|
3
|
+
#++
|
4
|
+
|
5
|
+
class String
|
6
|
+
|
7
|
+
def starts_with?(str)
|
8
|
+
self.index( str ) == 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def ends_with?(str)
|
12
|
+
self.rindex( str ) == self.length - str.length
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# _____ _
|
19
|
+
# |_ _|__ ___| |_
|
20
|
+
# | |/ _ \/ __| __|
|
21
|
+
# | | __/\__ \ |_
|
22
|
+
# |_|\___||___/\__|
|
23
|
+
#
|
24
|
+
# TODO
|
@@ -0,0 +1,163 @@
|
|
1
|
+
module MasterView
|
2
|
+
|
3
|
+
class DirectiveBase
|
4
|
+
include PluginLoadTracking
|
5
|
+
include DirectiveHelpers
|
6
|
+
|
7
|
+
# Register a class manually without regard to whether it inherits from DirectiveBase.
|
8
|
+
# Classes which derive from DirectiveBase will automatically be registered as they are
|
9
|
+
# loaded.
|
10
|
+
def self.register_directive(directive_class)
|
11
|
+
self.register_class(directive_class)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(attribute_value)
|
15
|
+
@attribute_value = attribute_value
|
16
|
+
end
|
17
|
+
|
18
|
+
#if this method exists, it will be called by renderer to save directive_call_stack before each method call
|
19
|
+
def save_directive_call_stack(directive_call_stack)
|
20
|
+
@directive_call_stack = directive_call_stack
|
21
|
+
end
|
22
|
+
|
23
|
+
# returns the full attribute name which is the mv_ns prefix + attr_name if that method has been provided, otherwise
|
24
|
+
# it default to the class name (without any module prefix) and it downcases the first letter
|
25
|
+
def self.full_attr_name(namespace_prefix)
|
26
|
+
namespace_prefix + (self.respond_to?(:attr_name) ? self.attr_name : self.name.split(':').last.downcase_first_letter)
|
27
|
+
end
|
28
|
+
|
29
|
+
#get the directives attribute value string
|
30
|
+
def attr_value
|
31
|
+
@attribute_value
|
32
|
+
end
|
33
|
+
|
34
|
+
#set the directives attribute value string
|
35
|
+
def attr_value=(attribute_value)
|
36
|
+
@attribute_value = attribute_value
|
37
|
+
end
|
38
|
+
|
39
|
+
#get attribute hash from tag
|
40
|
+
def attrs
|
41
|
+
@directive_call_stack.context[:tag].attributes
|
42
|
+
end
|
43
|
+
|
44
|
+
#set attribute hash for tag
|
45
|
+
def attrs=(attributes)
|
46
|
+
@directive_call_stack.context[:tag].attributes = attributes
|
47
|
+
end
|
48
|
+
|
49
|
+
#get attribute hash with lowercased keys and values, and cache it
|
50
|
+
def attrs_lckv
|
51
|
+
@attrs_lckv ||= lowercase_attribute_keys_and_values(attrs)
|
52
|
+
end
|
53
|
+
|
54
|
+
#get attribute hash with lowercased keys (and original values) and cache it
|
55
|
+
def attrs_lck
|
56
|
+
@attrs_lck ||= lowercase_attribute_keys(attrs)
|
57
|
+
end
|
58
|
+
|
59
|
+
#returns true if the value for lckey of the attribute hash with lowercased keys and values
|
60
|
+
#matches (lowercase) lcmatch string
|
61
|
+
def attr_lckv_matches(lckey, lcmatch)
|
62
|
+
(attrs_lckv[lckey] && attrs_lckv[lckey] == lcmatch.downcase) ? true : false
|
63
|
+
end
|
64
|
+
|
65
|
+
#output '<% '+str+' %>'
|
66
|
+
def erb(str)
|
67
|
+
ERB_START + str + ERB_END
|
68
|
+
end
|
69
|
+
|
70
|
+
#output '<%= '+str+' %>
|
71
|
+
def erb_content(str)
|
72
|
+
ERB_EVAL + str + ERB_END
|
73
|
+
end
|
74
|
+
|
75
|
+
#get tag_name
|
76
|
+
def tag_name
|
77
|
+
@directive_call_stack.context[:tag].tag_name
|
78
|
+
end
|
79
|
+
|
80
|
+
#set tag_name
|
81
|
+
def tag_name=(tag_name)
|
82
|
+
@directive_call_stack.context[:tag].tag_name = tag_name
|
83
|
+
end
|
84
|
+
|
85
|
+
#inside characters, cdata, or comment you can call this to get the characters passed
|
86
|
+
def data
|
87
|
+
@directive_call_stack.context[:content_part]
|
88
|
+
end
|
89
|
+
|
90
|
+
#set the data that will be passed to characters, cdata, or comment directives
|
91
|
+
def data=(data)
|
92
|
+
@directive_call_stack.context[:content_part]=data
|
93
|
+
end
|
94
|
+
|
95
|
+
# rolled up content from all children of the tag, note this will not be complete until hitting the end tag method :etag
|
96
|
+
def content
|
97
|
+
@directive_call_stack.context[:tag].content
|
98
|
+
end
|
99
|
+
|
100
|
+
#return rolled up content from all children as string, note this will not be complete until hitting the end tag method :etag
|
101
|
+
def content_str
|
102
|
+
content = @directive_call_stack.context[:tag].content
|
103
|
+
content = content.join if content.respond_to? :join
|
104
|
+
content
|
105
|
+
end
|
106
|
+
|
107
|
+
# replace the content from all children with a new value
|
108
|
+
def content=(content)
|
109
|
+
@directive_call_stack.context[:tag].content = content
|
110
|
+
end
|
111
|
+
|
112
|
+
#add single quotes around string
|
113
|
+
def quote(str)
|
114
|
+
'\''+str+'\''
|
115
|
+
end
|
116
|
+
|
117
|
+
def remove_strings_from_attr_value!
|
118
|
+
self.attr_value = remove_prepended_strings(attr_value)
|
119
|
+
end
|
120
|
+
|
121
|
+
#prepend string to attribute value adding a comma if attribute value was not empty
|
122
|
+
def prepend_to_attr_value!(str)
|
123
|
+
return attr_value if str.nil? || str.strip.empty?
|
124
|
+
av = str
|
125
|
+
av << ', ' << attr_value unless attr_value.strip.empty?
|
126
|
+
self.attr_value = av
|
127
|
+
end
|
128
|
+
|
129
|
+
#append string to attribute value adding a comma if attribute value was not empty
|
130
|
+
def append_to_attr_value!(str)
|
131
|
+
return attr_value if str.nil? || str.strip.empty?
|
132
|
+
av = attr_value
|
133
|
+
av << ', ' unless av.strip.empty?
|
134
|
+
av << str
|
135
|
+
self.attr_value = av
|
136
|
+
end
|
137
|
+
|
138
|
+
#merge merge_hash into hashes stored in attribute_value string
|
139
|
+
#hash_index is the zero based index of the hash you want to add to
|
140
|
+
def merge_hash_attr_value!(hash_index, merge_hash)
|
141
|
+
self.attr_value = merge_into_embedded_hash(attr_value, hash_index, merge_hash)
|
142
|
+
end
|
143
|
+
|
144
|
+
#calls non-evaling parse to split into string arguments
|
145
|
+
def parse_attr_value
|
146
|
+
parse(attr_value)
|
147
|
+
end
|
148
|
+
|
149
|
+
# check for common html options and return the hash
|
150
|
+
def common_html_options(attrs_lck)
|
151
|
+
options = {}
|
152
|
+
options[:class] = attrs_lck['class'] if attrs_lck['class']
|
153
|
+
options[:style] = attrs_lck['style'] if attrs_lck['style']
|
154
|
+
options[:tabindex] = attrs_lck['tabindex'] if attrs_lck['tabindex']
|
155
|
+
options[:accesskey] = attrs_lck['accesskey'] if attrs_lck['accesskey']
|
156
|
+
options[:disabled] = true if attrs_lck['disabled']
|
157
|
+
options[:readonly] = true if attrs_lck['readonly']
|
158
|
+
options
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|