masterview 0.2.5 → 0.3.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/CHANGELOG +31 -1
- data/README +70 -69
- data/RELEASE_NOTES +70 -64
- data/Rakefile +26 -27
- data/TODO +13 -29
- data/doc/about.html +246 -0
- data/doc/configuration.html +49 -36
- data/doc/developer.html +423 -41
- data/doc/directives.html +139 -51
- data/doc/guide.html +19 -9
- data/doc/index.html +90 -224
- data/doc/installation.html +36 -28
- data/doc/media_list.html +30 -20
- data/doc/simple_diagram.html +3 -5
- data/doc/stylesheets/masterview.css +16 -1
- data/examples/rails_app_config/masterview/settings.rb +2 -1
- data/init.rb +1 -1
- data/lib/#ChangeLog# +6 -0
- data/lib/masterview/analyzer.rb +48 -34
- data/lib/masterview/attr_string_parser.rb +5 -1
- data/lib/masterview/case_insensitive_hash.rb +69 -0
- data/lib/masterview/{pathname_extensions.rb → core_ext/pathname.rb} +0 -0
- data/lib/masterview/{string_extensions.rb → core_ext/string.rb} +0 -0
- data/lib/masterview/deprecated/directive_base.rb +362 -0
- data/lib/masterview/directive_base.rb +201 -179
- data/lib/masterview/directive_dsl.rb +457 -0
- data/lib/masterview/directive_helpers.rb +28 -141
- data/lib/masterview/directive_load_path.rb +388 -0
- data/lib/masterview/directive_metadata.rb +377 -0
- data/lib/masterview/directive_registry.rb +259 -69
- data/lib/masterview/directives/.metadata +16 -0
- data/lib/masterview/directives/attr.rb +9 -8
- data/lib/masterview/directives/block.rb +11 -14
- data/lib/masterview/directives/check_box.rb +13 -18
- data/lib/masterview/directives/collection_select.rb +15 -29
- data/lib/masterview/directives/content.rb +9 -3
- data/lib/masterview/directives/else.rb +15 -13
- data/lib/masterview/directives/elsif.rb +14 -13
- data/lib/masterview/directives/eval.rb +20 -0
- data/lib/masterview/directives/form.rb +56 -9
- data/lib/masterview/directives/form_remote.rb +26 -0
- data/lib/masterview/directives/global_inline_erb.rb +10 -14
- data/lib/masterview/directives/hidden_field.rb +11 -20
- data/lib/masterview/directives/if.rb +13 -12
- data/lib/masterview/directives/image_tag.rb +20 -28
- data/lib/masterview/directives/import.rb +5 -12
- data/lib/masterview/directives/import_render.rb +7 -19
- data/lib/masterview/directives/insert_generated_comment.rb +8 -11
- data/lib/masterview/directives/javascript_include.rb +21 -12
- data/lib/masterview/directives/link_to.rb +14 -8
- data/lib/masterview/directives/link_to_function.rb +22 -0
- data/lib/masterview/directives/link_to_if.rb +15 -13
- data/lib/masterview/directives/link_to_remote.rb +13 -8
- data/lib/masterview/directives/omit_tag.rb +32 -16
- data/lib/masterview/directives/password_field.rb +10 -22
- data/lib/masterview/directives/radio_button.rb +11 -22
- data/lib/masterview/directives/replace.rb +7 -8
- data/lib/masterview/directives/select.rb +11 -24
- data/lib/masterview/directives/stylesheet_link.rb +20 -12
- data/lib/masterview/directives/submit.rb +11 -5
- data/lib/masterview/directives/text_area.rb +10 -23
- data/lib/masterview/directives/text_field.rb +10 -22
- data/lib/masterview/exceptions.rb +21 -0
- data/lib/masterview/extras/app/controllers/masterview_controller.rb +102 -75
- data/lib/masterview/extras/app/views/layouts/masterview_admin.rhtml +24 -23
- data/lib/masterview/extras/app/views/layouts/masterview_admin_config.rhtml +81 -0
- data/lib/masterview/extras/app/views/masterview/admin/configuration.rhtml +5 -1
- data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +2 -2
- data/lib/masterview/extras/app/views/masterview/admin/directives.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/features.rhtml +5 -79
- data/lib/masterview/extras/app/views/masterview/admin/interact.rhtml +5 -0
- data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +3 -71
- data/lib/masterview/extras/init_mv_admin_pages.rb +42 -23
- data/lib/masterview/filter_helpers.rb +26 -0
- data/lib/masterview/initializer.rb +99 -53
- data/lib/masterview/io.rb +19 -15
- data/lib/masterview/keyword_expander.rb +7 -2
- data/lib/masterview/masterview_info.rb +229 -23
- data/lib/masterview/masterview_version.rb +2 -2
- data/lib/masterview/parser.rb +275 -105
- data/lib/masterview/parser_helpers.rb +54 -0
- data/lib/masterview/rails_ext/action_controller_erb_direct.rb +29 -0
- data/lib/masterview/rails_ext/action_controller_reparse_checking.rb +27 -0
- data/lib/masterview/{extras/init_rails_erb_mv_direct.rb → rails_ext/action_view_erb_direct.rb} +12 -59
- data/lib/masterview/template_spec.rb +3 -2
- data/lib/masterview.rb +21 -12
- data/lib/rexml/parsers/baseparser_with_doctype_fix.rb +473 -0
- data/lib/rexml/parsers/sax2parser_with_doctype_fix.rb +243 -0
- data/test/directive_test_helper.rb +135 -0
- data/test/fixtures/directives/id_check.rb +18 -0
- data/test/fixtures/directives/test_directive_events.rb +70 -0
- data/test/test_helper.rb +18 -5
- data/test/tmp/views/layouts/product.rhtml +10 -10
- data/test/tmp/views/product/_form.rhtml +4 -4
- data/test/tmp/views/product/_product.rhtml +3 -3
- data/test/tmp/views/product/destroy.rhtml +5 -5
- data/test/tmp/views/product/edit.rhtml +4 -4
- data/test/tmp/views/product/list.rhtml +3 -3
- data/test/tmp/views/product/new.rhtml +4 -4
- data/test/tmp/views/product/show.rhtml +2 -2
- data/test/unit/attr_string_parser_test.rb +105 -0
- data/test/unit/case_insensitive_hash_mod_test.rb +104 -0
- data/test/unit/config_settings_test.rb +13 -1
- data/test/unit/default_generate_mio_filter_test.rb +3 -3
- data/test/unit/deprecated_directive_base_test.rb +30 -0
- data/test/unit/directive_attr_test.rb +111 -35
- data/test/unit/directive_base_test.rb +520 -1
- data/test/unit/directive_block_test.rb +30 -22
- data/test/unit/directive_content_test.rb +24 -11
- data/test/unit/directive_else_test.rb +18 -15
- data/test/unit/directive_elsif_test.rb +17 -15
- data/test/unit/directive_form_remote_test.rb +59 -0
- data/test/unit/directive_form_test.rb +31 -39
- data/test/unit/directive_global_inline_erb_test.rb +28 -17
- data/test/unit/directive_grid_test_notready.rb +38 -0
- data/test/unit/directive_helpers_test.rb +39 -0
- data/test/unit/directive_hidden_field_test.rb +44 -29
- data/test/unit/directive_if_test.rb +10 -7
- data/test/unit/directive_image_tag_test.rb +69 -61
- data/test/unit/directive_import_render_test.rb +28 -38
- data/test/unit/directive_import_test.rb +16 -14
- data/test/unit/directive_insert_generated_comment_test.rb +32 -0
- data/test/unit/directive_javascript_include_test.rb +40 -43
- data/test/unit/directive_link_to_function_test.rb +40 -0
- data/test/unit/directive_link_to_if_test.rb +52 -12
- data/test/unit/directive_link_to_remote_test.rb +58 -0
- data/test/unit/directive_link_to_test.rb +46 -31
- data/test/unit/directive_load_path_test.rb +257 -0
- data/test/unit/directive_metadata_test.rb +313 -0
- data/test/unit/directive_omit_tag_test.rb +73 -21
- data/test/unit/directive_password_field_test.rb +44 -38
- data/test/unit/directive_registry_test.rb +44 -0
- data/test/unit/directive_replace_test.rb +28 -12
- data/test/unit/directive_stylesheet_link_test.rb +43 -36
- data/test/unit/directive_submit_test.rb +29 -30
- data/test/unit/directive_text_area_test.rb +40 -36
- data/test/unit/directive_text_field_test.rb +44 -38
- data/test/unit/example_directive_child_events_test.rb +41 -0
- data/test/unit/example_test.rb +31 -4
- data/test/unit/file_mio_test.rb +18 -13
- data/test/unit/filter_helpers_test.rb +10 -8
- data/test/unit/find_directive_parent_test.rb +174 -0
- data/test/unit/keyword_expander_test.rb +4 -2
- data/test/unit/mio_test.rb +18 -11
- data/test/unit/mtime_string_hash_mio_tree_test.rb +5 -1
- data/test/unit/parser_test.rb +41 -29
- data/test/unit/pathname_extensions_test.rb +1 -1
- data/test/unit/run_parser_test.rb +2 -2
- data/test/unit/simplified_directive_base_test.rb +256 -0
- data/test/unit/string_hash_mio_test.rb +5 -1
- data/test/unit/template_file_watcher_test.rb +2 -2
- data/test/unit/template_test.rb +221 -46
- metadata +86 -45
- data/lib/masterview/directives/testfilter.rb +0 -55
- data/lib/masterview/extras/init_rails_reparse_checking.rb +0 -62
@@ -1,24 +1,25 @@
|
|
1
1
|
module MasterView
|
2
2
|
module Directives
|
3
3
|
|
4
|
-
#outputs an elsif/end block around the text tags and remove previous end (from if)
|
4
|
+
# outputs an elsif/end block around the text tags and remove previous end (from if)
|
5
|
+
#
|
5
6
|
class Elsif < MasterView::DirectiveBase
|
6
|
-
def priority
|
7
|
-
DirectivePriorities::High
|
8
|
-
end
|
9
7
|
|
10
|
-
|
8
|
+
metadata :priority => 'High',
|
9
|
+
:category => 'erb',
|
10
|
+
:description => 'Used in conjunction with the mv:if directive to allow you to create if... elsif... end blocks'
|
11
|
+
|
12
|
+
# remove the last <% end -%> from the parent tag's content and add a <% else -%> instead.
|
13
|
+
# This is a continuation of previous if or elsif statement.
|
14
|
+
event :before_stag do
|
11
15
|
tag = @directive_call_stack.context[:tag]
|
12
|
-
delete_last_in_parent(tag,
|
13
|
-
|
14
|
-
ret << erb('elsif '+attr_value)
|
15
|
-
ret << directive_call_stack.render
|
16
|
+
delete_last_in_parent(tag, erb_eval('end') )
|
17
|
+
render erb_eval( 'elsif', attr_value )
|
16
18
|
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ret << erb('end')
|
20
|
+
# output <% end -%> after everything
|
21
|
+
event :after_etag do
|
22
|
+
render erb_eval( 'end' )
|
22
23
|
end
|
23
24
|
|
24
25
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
# outputs a <% attr_value %> before the element
|
5
|
+
# example: <foo><bar mv:eval="i = 1">baz</bar></foo>
|
6
|
+
# becomes: <foo><% i = 1 %><bar>baz</bar></foo>
|
7
|
+
# Inspired by Sergey Shalatskly's silent tag
|
8
|
+
class Eval < MasterView::DirectiveBase
|
9
|
+
|
10
|
+
metadata :priority => 'MediumHigh',
|
11
|
+
:category => 'erb',
|
12
|
+
:description => 'Inserts an rhtml evaluation expression for the attribute value prior to the element'
|
13
|
+
|
14
|
+
event :before_stag do
|
15
|
+
render erb_eval( attr_value )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,19 +1,66 @@
|
|
1
1
|
module MasterView
|
2
2
|
module Directives
|
3
3
|
|
4
|
-
# creates
|
4
|
+
# creates form_tag block and ending form tag from values in form
|
5
|
+
#
|
5
6
|
class Form < MasterView::DirectiveBase
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
|
8
|
+
metadata :priority => :default,
|
9
|
+
:category => 'form',
|
10
|
+
:description => 'Replaces the start and end tags of the element using the Rails form_tag helper and an ending form tag',
|
11
|
+
:element_usage => 'form'
|
12
|
+
|
13
|
+
attr_arg :url_for_options
|
14
|
+
attr_arg :options, :append_element_attrs => [:common_html, :method]
|
15
|
+
attr_arg :parameters_for_url, :varargs => true
|
16
|
+
|
17
|
+
event :stag do
|
18
|
+
merge_hash_into_str( {:multipart => true}, @options ) if element_attrs.get_lowercase_str_value('enctype') == 'multipart/form-data'
|
19
|
+
render erb_content( 'form_tag', :url_for_options, :options, :parameters_for_url )
|
12
20
|
end
|
13
21
|
|
14
|
-
|
15
|
-
|
22
|
+
event :etag do
|
23
|
+
render '</form>'
|
16
24
|
end
|
25
|
+
|
17
26
|
end
|
27
|
+
|
18
28
|
end
|
19
29
|
end
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
=begin
|
34
|
+
|
35
|
+
module MasterView
|
36
|
+
module Directives
|
37
|
+
|
38
|
+
# once rails 1.2 is released we can use the form_tag block method of the helper but this does not work prior to rails 1.2
|
39
|
+
# creates form_tag block from values in form
|
40
|
+
#
|
41
|
+
class Form < MasterView::DirectiveBase
|
42
|
+
|
43
|
+
metadata :priority => :default,
|
44
|
+
:category => 'form',
|
45
|
+
:description => 'Replaces the start and end tags of the element using the Rails form_tag block helper',
|
46
|
+
:element_usage => 'form'
|
47
|
+
|
48
|
+
attr_arg :url_for_options
|
49
|
+
attr_arg :options, :append_element_attrs => [:common_html, :method]
|
50
|
+
attr_arg :parameters_for_url, :varargs => true
|
51
|
+
|
52
|
+
event :stag do
|
53
|
+
merge_hash_into_str( {:multipart => true}, @options ) if element_attrs.get_lowercase_str_value('enctype') == 'multipart/form-data'
|
54
|
+
render erb_eval( prepare_output('form_tag', :url_for_options, :options, :parameters_for_url)+' do' ) # call prepare_output directly so do won't be embedded in method call
|
55
|
+
end
|
56
|
+
|
57
|
+
event :etag do
|
58
|
+
render erb_eval( 'end' )
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
=end
|
66
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
# creates form_remote_tag and closing form tag from values in form
|
5
|
+
#
|
6
|
+
class FormRemote < MasterView::DirectiveBase
|
7
|
+
|
8
|
+
metadata :priority => :default,
|
9
|
+
:category => 'form',
|
10
|
+
:description => 'Replaces the start and end tags of the element using the Rails form_remote_tag helper and </form> for Ajax-enabled form submission using the Prototype library',
|
11
|
+
:element_usage => 'form'
|
12
|
+
|
13
|
+
attr_arg :options, :append_element_attrs => [:common_html, :method]
|
14
|
+
|
15
|
+
event :stag do
|
16
|
+
merge_hash_into_str( {:multipart => true}, @options ) if element_attrs.get_lowercase_str_value('enctype') == 'multipart/form-data'
|
17
|
+
render erb_content( 'form_remote_tag', :options )
|
18
|
+
end
|
19
|
+
|
20
|
+
event :etag do
|
21
|
+
render '</form>'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -3,24 +3,21 @@ module MasterView
|
|
3
3
|
|
4
4
|
#outputs a block around the text tags, if left bracket count is higher than right
|
5
5
|
#assume that the end is a right bracket otherwise use end
|
6
|
-
class
|
6
|
+
class GlobalInlineErb < MasterView::DirectiveBase
|
7
|
+
|
8
|
+
metadata :priority => 'Low',
|
9
|
+
:global_directive? => true,
|
10
|
+
:category => 'erb',
|
11
|
+
:description => 'Inline substitution notation for Erb expressions'
|
12
|
+
|
7
13
|
def initialize(attribute_value = nil)
|
8
14
|
super(attribute_value)
|
9
15
|
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def global_directive?
|
16
|
-
true
|
17
|
-
end
|
18
|
-
|
19
|
-
def stag(dcs)
|
20
|
-
attrs.each do |key, value|
|
17
|
+
event :before_stag do
|
18
|
+
element_attrs.each do |key, value|
|
21
19
|
replace_with_erb!( value )
|
22
20
|
end
|
23
|
-
dcs.render
|
24
21
|
end
|
25
22
|
|
26
23
|
def characters(dcs)
|
@@ -28,12 +25,11 @@ module MasterView
|
|
28
25
|
dcs.render
|
29
26
|
end
|
30
27
|
|
31
|
-
private
|
32
|
-
|
33
28
|
def replace_with_erb!(value)
|
34
29
|
subs = value.gsub!( MasterView::InlineErbSubstitutionRegex, '<%\1%>' )
|
35
30
|
end
|
36
31
|
|
32
|
+
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -1,29 +1,20 @@
|
|
1
1
|
module MasterView
|
2
2
|
module Directives
|
3
3
|
|
4
|
-
class
|
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]
|
4
|
+
class HiddenField < MasterView::DirectiveBase
|
13
5
|
|
14
|
-
|
15
|
-
|
6
|
+
metadata :priority => :default,
|
7
|
+
:category => 'form',
|
8
|
+
:description => 'Replaces the element with a hidden input element using the Rails hidden_tag helper',
|
9
|
+
:element_usage => 'input'
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
attr_arg :obj, :quote => true
|
12
|
+
attr_arg :method, :quote => true
|
13
|
+
attr_arg :value, :default => nil
|
14
|
+
attr_arg :options, :append_element_attrs => [:common_html]
|
21
15
|
|
22
|
-
|
23
|
-
|
24
|
-
a << method
|
25
|
-
a << attr_value unless attr_value.strip.empty?
|
26
|
-
erb_content(a.join(', '))
|
16
|
+
event :element do
|
17
|
+
render erb_content( 'hidden_field', :obj, :method, :value, :options )
|
27
18
|
end
|
28
19
|
|
29
20
|
end
|
@@ -1,22 +1,23 @@
|
|
1
1
|
module MasterView
|
2
2
|
module Directives
|
3
3
|
|
4
|
-
#outputs an if/end block around the text tags
|
4
|
+
# outputs an if/end block around the text tags
|
5
|
+
#
|
5
6
|
class If < MasterView::DirectiveBase
|
6
|
-
def priority
|
7
|
-
DirectivePriorities::High
|
8
|
-
end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
metadata :priority => 'High',
|
9
|
+
:category => 'erb',
|
10
|
+
:description => 'Wraps the element with an if... end block using the attribute value for the condition'
|
11
|
+
|
12
|
+
#TODO: omit element entirely if attr_value == 'false'
|
13
|
+
#TODO: don't need to generate conditional block wrapping if attr_value == 'true'
|
14
|
+
|
15
|
+
event :before_stag do
|
16
|
+
render erb_eval( 'if', attr_value )
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
ret << directive_call_stack.render
|
19
|
-
ret << erb('end')
|
19
|
+
event :after_etag do
|
20
|
+
render erb_eval( 'end' )
|
20
21
|
end
|
21
22
|
|
22
23
|
end
|
@@ -4,42 +4,34 @@ module MasterView
|
|
4
4
|
# creates a image_tag.
|
5
5
|
# if path is specified in attr_value then it will be used exactly as listed, otherwise if attr_value is empty
|
6
6
|
# then masterview will attempt to find the public/images in the string and infer the path from what follows.
|
7
|
-
# otherwise it will simply use the src path.
|
7
|
+
# otherwise it will simply use the src path.
|
8
8
|
# If both width and height attr values are specified then it will build the :size option from them.
|
9
9
|
# Other html attributes will be passed into image_tag options.
|
10
|
-
class
|
10
|
+
class ImageTag < MasterView::DirectiveBase
|
11
11
|
|
12
12
|
# /public\/images\/(.*)/
|
13
13
|
IMAGE_SRC_EXTRACT_REGEX = MasterView::ConfigSettings.template_asset_base_ref_pattern[:images]
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
metadata :priority => :default,
|
16
|
+
:category => 'asset',
|
17
|
+
:description => 'Replaces the element using the Rails image_tag helper.',
|
18
|
+
:element_usage => 'img'
|
19
|
+
|
20
|
+
attr_arg :src
|
21
|
+
attr_arg :options, :append_element_attrs => [:common_html]
|
22
|
+
|
23
|
+
event :element do
|
24
|
+
if (@src.nil? or @src.empty?) and src_attr = element_attrs[:src]
|
25
|
+
if match = IMAGE_SRC_EXTRACT_REGEX.match(src_attr)
|
26
|
+
@src = match[1]
|
27
|
+
else
|
28
|
+
@src = src_attr
|
29
|
+
end
|
25
30
|
end
|
26
|
-
|
27
|
-
|
28
|
-
attrs.delete('src') # delete this if exists, path has already been specified
|
29
|
-
|
30
|
-
width = attrs_lck['width']
|
31
|
-
height = attrs_lck['height']
|
32
|
-
if width && height
|
33
|
-
attrs.delete('width') #delete these since being used in size
|
34
|
-
attrs.delete('height')
|
35
|
-
attrs[:size] = "#{width}x#{height}"
|
36
|
-
end
|
37
|
-
|
38
|
-
options = symbolize_sort_and_serialize_hash_to_str(attrs)
|
39
|
-
image_tag_params += (', '+options) unless options.empty?
|
40
|
-
|
41
|
-
erb_content('image_tag ' + image_tag_params)
|
31
|
+
@src = quote(@src) unless @src.nil?
|
32
|
+
render erb_content('image_tag', :src, :options)
|
42
33
|
end
|
34
|
+
|
43
35
|
end
|
44
36
|
|
45
37
|
end
|
@@ -3,20 +3,13 @@ module MasterView
|
|
3
3
|
|
4
4
|
# just eat this output since it is only used for design time
|
5
5
|
class Import < MasterView::DirectiveBase
|
6
|
-
def priority
|
7
|
-
DirectivePriorities::VeryHigh
|
8
|
-
end
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def etag(dcs)
|
15
|
-
tag = dcs.context[:tag]
|
16
|
-
tag.content = [] # clear out any content including from children
|
17
|
-
nil
|
18
|
-
end
|
7
|
+
metadata :priority => 'VeryHigh',
|
8
|
+
:category => 'processing',
|
9
|
+
:description => 'Design-time directive to mark a snapshot of generated code'
|
19
10
|
|
11
|
+
event :element, :render => :nothing
|
12
|
+
|
20
13
|
end
|
21
14
|
end
|
22
15
|
end
|
@@ -1,27 +1,15 @@
|
|
1
1
|
module MasterView
|
2
2
|
module Directives
|
3
3
|
|
4
|
-
#
|
5
|
-
class
|
6
|
-
def priority
|
7
|
-
DirectivePriorities::VeryHigh
|
8
|
-
end
|
4
|
+
# output the render partial after expanding keywords
|
5
|
+
class ImportRender < MasterView::DirectiveBase
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@attribute_value = Renderer.last_renderer.keyword_expander.expand_keywords(attribute_value)
|
14
|
-
end
|
7
|
+
metadata :priority => 'VeryHigh',
|
8
|
+
:category => 'processing',
|
9
|
+
:description => 'Design-time directive to mark a snapshot of generated partial code, outputs render partial after expanding keywords'
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def etag(dcs)
|
21
|
-
tag = dcs.context[:tag]
|
22
|
-
tag.content = [] # clear out any content including from children
|
23
|
-
ret = []
|
24
|
-
ret << erb_content('render( '+attr_value+' )')
|
11
|
+
event :element do
|
12
|
+
render erb_content( 'render', self.renderer.keyword_expander.expand_keywords(attr_value) )
|
25
13
|
end
|
26
14
|
|
27
15
|
end
|
@@ -5,25 +5,22 @@ module MasterView
|
|
5
5
|
# and should not be edited, else changes could be lost. The standard generated-file
|
6
6
|
# comment includes the path to the original file that should be edited.
|
7
7
|
#
|
8
|
-
class
|
8
|
+
class InsertGeneratedComment < MasterView::DirectiveBase
|
9
9
|
|
10
10
|
# Configured value for generated comment text is eval'd to support #{template_path} field substitution
|
11
11
|
Comment_eval_template = 'comment_text = "' + MasterView::GeneratedCommentText + '"'
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
metadata :priority => 'VeryLow',
|
14
|
+
:category => 'internal'
|
15
|
+
|
16
|
+
attr_arg :comment_template_path
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
template_path = attr_value
|
18
|
+
event :after_stag do
|
19
|
+
template_path = @comment_template_path
|
20
20
|
comment_text = ''
|
21
21
|
eval(Comment_eval_template, binding)
|
22
22
|
comment = "\n<%\n#{comment_text}\n-%>" # "\n#{ERB_EVAL_START.strip()}\n#{comment_text}\n#{ERB_EVAL_END.strip()}"
|
23
|
-
|
24
|
-
ret = []
|
25
|
-
ret << directive_call_stack.render
|
26
|
-
ret << comment
|
23
|
+
render comment
|
27
24
|
end
|
28
25
|
|
29
26
|
end
|
@@ -1,25 +1,34 @@
|
|
1
1
|
module MasterView
|
2
2
|
module Directives
|
3
3
|
|
4
|
-
#creates a
|
5
|
-
|
4
|
+
#creates a javascript_include asset helper
|
5
|
+
#
|
6
|
+
class JavascriptInclude < MasterView::DirectiveBase
|
6
7
|
|
7
8
|
# /public\/javascripts\/(.*)/
|
8
9
|
JAVASCRIPT_SRC_EXTRACT_REGEX = MasterView::ConfigSettings.template_asset_base_ref_pattern[:javascripts]
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
metadata :priority => :default,
|
12
|
+
:category => 'asset',
|
13
|
+
:description => 'Replaces the element with the Rails javascript_include_tag helper',
|
14
|
+
:element_usage => 'script'
|
15
|
+
|
16
|
+
attr_arg :src, :varargs => true
|
12
17
|
|
13
|
-
|
14
|
-
src
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
event :element do
|
19
|
+
if @src.nil? or @src.empty?
|
20
|
+
if src_attr = element_attrs[:src]
|
21
|
+
if match = JAVASCRIPT_SRC_EXTRACT_REGEX.match(src_attr)
|
22
|
+
@src = [match[1]]
|
23
|
+
else
|
24
|
+
@src = [src_attr]
|
25
|
+
end
|
26
|
+
end
|
20
27
|
end
|
21
|
-
|
28
|
+
@src.collect! { |x| x.starts_with?(':') ? x : quote(x) }
|
29
|
+
render erb_content('javascript_include_tag', :src)
|
22
30
|
end
|
31
|
+
|
23
32
|
end
|
24
33
|
|
25
34
|
end
|
@@ -2,16 +2,22 @@ module MasterView
|
|
2
2
|
module Directives
|
3
3
|
|
4
4
|
#creates a link_to
|
5
|
-
class
|
6
|
-
|
7
|
-
|
5
|
+
class LinkTo < MasterView::DirectiveBase
|
6
|
+
|
7
|
+
metadata :priority => :default,
|
8
|
+
:category => 'link',
|
9
|
+
:description => 'Replaces the element using the Rails link_to helper',
|
10
|
+
:element_usage => 'a'
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
attr_arg :name do |value, args| if value.include?('=>') : args.unshift(value); end; nil; end # if hash push back on, discard name
|
13
|
+
attr_arg :options, :default => {}
|
14
|
+
attr_arg :html_options, :default => {}, :append_element_attrs => [:common_html]
|
15
|
+
attr_arg :params, :varargs => true
|
16
|
+
|
17
|
+
event :element do
|
18
|
+
render erb_content('link_to', quote(content_string), :options, :html_options, :params)
|
14
19
|
end
|
20
|
+
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
#creates a link_to_function
|
5
|
+
class LinkToFunction < MasterView::DirectiveBase
|
6
|
+
|
7
|
+
metadata :priority => :default,
|
8
|
+
:category => 'link',
|
9
|
+
:description => 'Replaces the element with the Rails link_to_function helper which creates a link which calls a JavaScript function.',
|
10
|
+
:element_usage => 'a'
|
11
|
+
|
12
|
+
attr_arg :function
|
13
|
+
attr_arg :html_options, :append_element_attrs => [:common_html]
|
14
|
+
|
15
|
+
event :element do
|
16
|
+
@function = quote(@function, '"') unless @function.strip =~ /^('|")/ # quote unless already quoted, use double quote
|
17
|
+
render erb_content('link_to_function', quote(content_string), :function, :html_options)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module MasterView
|
2
2
|
module Directives
|
3
3
|
|
4
|
-
class
|
5
|
-
|
6
|
-
|
4
|
+
class LinkToIf < MasterView::DirectiveBase
|
5
|
+
|
6
|
+
metadata :priority => :default,
|
7
|
+
:category => 'link',
|
8
|
+
:description => 'Replaces the element using the Rails link_to_if helper',
|
9
|
+
:element_usage => 'a'
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
self.content=''
|
17
|
-
erb_content(a.join(', '))
|
11
|
+
attr_arg :condition
|
12
|
+
attr_arg :name do |value, args| if value.include?('=>') : args.unshift(value); end; nil; end # if hash push back on, discard name
|
13
|
+
attr_arg :options, :default => {}
|
14
|
+
attr_arg :html_options, :default => {}, :append_element_attrs => [:common_html]
|
15
|
+
attr_arg :params, :varargs => true #including the block
|
16
|
+
|
17
|
+
event :element do
|
18
|
+
render erb_content('link_to_if', :condition, quote(content_string), :options, :html_options, :params)
|
18
19
|
end
|
20
|
+
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -2,16 +2,21 @@ module MasterView
|
|
2
2
|
module Directives
|
3
3
|
|
4
4
|
#creates a link_to_remote
|
5
|
-
class
|
6
|
-
|
7
|
-
|
5
|
+
class LinkToRemote < MasterView::DirectiveBase
|
6
|
+
|
7
|
+
metadata :priority => :default,
|
8
|
+
:category => 'link',
|
9
|
+
:description => 'Replaces the element using the Rails link_to_remote helper',
|
10
|
+
:element_usage => 'a'
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
attr_arg :name do |value, args| if value.include?('=>') : args.unshift(value); end; nil; end # if hash push back on, discard name
|
13
|
+
attr_arg :options, :default => {}
|
14
|
+
attr_arg :html_options, :default => {}, :append_element_attrs => [:common_html]
|
15
|
+
|
16
|
+
event :element do
|
17
|
+
render erb_content('link_to_remote', quote(content_string), :options, :html_options)
|
14
18
|
end
|
19
|
+
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|