hobo 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/hobo +1 -1
- data/hobo_files/plugin/CHANGES.txt +302 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +2 -9
- data/hobo_files/plugin/generators/hobo_model/templates/model.rb +1 -1
- data/hobo_files/plugin/generators/hobo_model_resource/hobo_model_resource_generator.rb +0 -2
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo-rapid.js +76 -46
- data/hobo_files/plugin/generators/hobo_rapid/templates/lowpro.js +25 -18
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/application.css +29 -11
- data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +2 -2
- data/hobo_files/plugin/init.rb +0 -1
- data/hobo_files/plugin/lib/active_record/has_many_association.rb +3 -0
- data/hobo_files/plugin/lib/hobo.rb +12 -8
- data/hobo_files/plugin/lib/hobo/bundle.rb +1 -1
- data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +1 -1
- data/hobo_files/plugin/lib/hobo/dryml/parser/attribute.rb +41 -0
- data/hobo_files/plugin/lib/hobo/dryml/parser/base_parser.rb +253 -0
- data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +26 -0
- data/hobo_files/plugin/lib/hobo/dryml/parser/element.rb +27 -0
- data/hobo_files/plugin/lib/hobo/dryml/parser/elements.rb +45 -0
- data/hobo_files/plugin/lib/hobo/dryml/parser/source.rb +58 -0
- data/hobo_files/plugin/lib/hobo/dryml/parser/text.rb +13 -0
- data/hobo_files/plugin/lib/hobo/dryml/parser/tree_parser.rb +67 -0
- data/hobo_files/plugin/lib/hobo/dryml/scoped_variables.rb +10 -5
- data/hobo_files/plugin/lib/hobo/dryml/template.rb +48 -27
- data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +28 -13
- data/hobo_files/plugin/lib/hobo/hobo_helper.rb +3 -1
- data/hobo_files/plugin/lib/hobo/model.rb +70 -10
- data/hobo_files/plugin/lib/hobo/model_controller.rb +49 -34
- data/hobo_files/plugin/lib/hobo/model_router.rb +10 -2
- data/hobo_files/plugin/lib/hobo/rapid_helper.rb +1 -0
- data/hobo_files/plugin/lib/hobo/scopes.rb +15 -0
- data/hobo_files/plugin/lib/hobo/scopes/apply_scopes.rb +23 -0
- data/hobo_files/plugin/lib/hobo/scopes/association_proxy_extensions.rb +4 -2
- data/hobo_files/plugin/lib/hobo/scopes/automatic_scopes.rb +34 -7
- data/hobo_files/plugin/lib/hobo/scopes/defined_scope_proxy_extender.rb +3 -1
- data/hobo_files/plugin/lib/hobo/scopes/scoped_proxy.rb +1 -5
- data/hobo_files/plugin/taglibs/rapid.dryml +33 -24
- data/hobo_files/plugin/taglibs/rapid_editing.dryml +6 -5
- data/hobo_files/plugin/taglibs/rapid_forms.dryml +37 -31
- data/hobo_files/plugin/taglibs/rapid_generics.dryml +68 -27
- data/hobo_files/plugin/taglibs/rapid_navigation.dryml +5 -8
- data/hobo_files/plugin/taglibs/rapid_pages.dryml +71 -47
- data/hobo_files/plugin/taglibs/rapid_plus.dryml +4 -5
- data/hobo_files/plugin/taglibs/rapid_support.dryml +11 -4
- metadata +23 -6
- data/hobo_files/plugin/lib/rexml.rb +0 -443
@@ -0,0 +1,26 @@
|
|
1
|
+
module Hobo::Dryml::Parser
|
2
|
+
|
3
|
+
class Document < REXML::Document
|
4
|
+
|
5
|
+
attr_accessor :default_attribute_value
|
6
|
+
|
7
|
+
def initialize(source=nil, context={})
|
8
|
+
super(nil, context)
|
9
|
+
@elements = Hobo::Dryml::Parser::Elements.new(self)
|
10
|
+
if source.kind_of? Document
|
11
|
+
@context = source.context
|
12
|
+
super source
|
13
|
+
else
|
14
|
+
build( source )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
private
|
20
|
+
def build( source )
|
21
|
+
Hobo::Dryml::Parser::TreeParser.new( source, self ).parse
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Hobo::Dryml::Parser
|
2
|
+
|
3
|
+
class Element < REXML::Element
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
super
|
7
|
+
@elements = Hobo::Dryml::Parser::Elements.new(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
def dryml_name
|
11
|
+
expanded_name.sub(/:.*/, "")
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :start_tag_source, :source_offset
|
15
|
+
|
16
|
+
attr_writer :has_end_tag
|
17
|
+
def has_end_tag?
|
18
|
+
@has_end_tag
|
19
|
+
end
|
20
|
+
|
21
|
+
def parameter_tag?
|
22
|
+
expanded_name =~ /:$/
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Hobo::Dryml::Parser
|
2
|
+
|
3
|
+
class Element < REXML::Element
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
super
|
7
|
+
@elements = Hobo::Dryml::Parser::Elements.new(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
def dryml_name
|
11
|
+
expanded_name.sub(/:.*/, "")
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :start_tag_source, :source_offset
|
15
|
+
|
16
|
+
attr_writer :has_end_tag
|
17
|
+
def has_end_tag?
|
18
|
+
@has_end_tag
|
19
|
+
end
|
20
|
+
|
21
|
+
def parameter_tag?
|
22
|
+
expanded_name =~ /:$/
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
class Elements < REXML::Elements
|
28
|
+
|
29
|
+
# Override to ensure DRYML elements are created
|
30
|
+
def add(element=nil)
|
31
|
+
rv = nil
|
32
|
+
if element.nil?
|
33
|
+
Hobo::Dryml::Parser::Element.new("", self, @element.context)
|
34
|
+
elsif not element.kind_of?(Element)
|
35
|
+
Hobo::Dryml::Parser::Element.new(element, self, @element.context)
|
36
|
+
else
|
37
|
+
@element << element
|
38
|
+
element.context = @element.context
|
39
|
+
element
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Hobo::Dryml::Parser
|
2
|
+
|
3
|
+
# A REXML source that keeps track of where in the buffer it is
|
4
|
+
class Source < REXML::Source
|
5
|
+
|
6
|
+
def initialize(src)
|
7
|
+
super(src)
|
8
|
+
@buffer_offset = 0
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :last_match_offset
|
12
|
+
|
13
|
+
def remember_match(m)
|
14
|
+
if m
|
15
|
+
@last_match = m
|
16
|
+
@last_match_offset = @buffer_offset + m.begin(0)
|
17
|
+
@orig[@last_match_offset..@last_match_offset+m[0].length] == @buffer[m.begin(0)..m.end(0)]
|
18
|
+
end
|
19
|
+
m
|
20
|
+
end
|
21
|
+
|
22
|
+
def advance_buffer(md)
|
23
|
+
@buffer = md.post_match
|
24
|
+
@buffer_offset += md.end(0)
|
25
|
+
end
|
26
|
+
|
27
|
+
def scan(pattern, cons=false)
|
28
|
+
raise '!'
|
29
|
+
return nil if @buffer.nil?
|
30
|
+
rv = @buffer.scan(pattern)
|
31
|
+
if cons and rv.size > 0
|
32
|
+
advance_buffer(Regexp.last_match)
|
33
|
+
end
|
34
|
+
rv
|
35
|
+
end
|
36
|
+
|
37
|
+
def consume(pattern)
|
38
|
+
md = remember_match(pattern.match(@buffer))
|
39
|
+
if md
|
40
|
+
advance_buffer(md)
|
41
|
+
@buffer
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def match(pattern, cons=false)
|
46
|
+
md = remember_match(pattern.match(@buffer))
|
47
|
+
advance_buffer(md) if cons and md
|
48
|
+
return md
|
49
|
+
end
|
50
|
+
|
51
|
+
def current_line
|
52
|
+
pos = last_match_offset || 0
|
53
|
+
[0, 0, @orig[0..pos].count("\n") + 1]
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Hobo::Dryml::Parser
|
2
|
+
|
3
|
+
class Text < REXML::Text
|
4
|
+
|
5
|
+
def parent=(parent)
|
6
|
+
# Bypass immediate super
|
7
|
+
REXML::Child.instance_method(:parent=).bind(self).call(parent)
|
8
|
+
Text.check(@string, /</, nil) if @raw and @parent && Text.respond_to?(:check)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Hobo::Dryml::Parser
|
2
|
+
|
3
|
+
class TreeParser < REXML::Parsers::TreeParser
|
4
|
+
def initialize( source, build_context = Document.new )
|
5
|
+
@build_context = build_context
|
6
|
+
@parser = Hobo::Dryml::Parser::BaseParser.new(source)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def parse
|
11
|
+
tag_stack = []
|
12
|
+
in_doctype = false
|
13
|
+
entities = nil
|
14
|
+
begin
|
15
|
+
while true
|
16
|
+
event = @parser.pull
|
17
|
+
#STDERR.puts "TREEPARSER GOT #{event.inspect}"
|
18
|
+
case event[0]
|
19
|
+
when :end_document
|
20
|
+
unless tag_stack.empty?
|
21
|
+
#raise ParseException.new("No close tag for #{tag_stack.inspect}")
|
22
|
+
raise ParseException.new("No close tag for #{@build_context.xpath}")
|
23
|
+
end
|
24
|
+
return
|
25
|
+
when :start_element
|
26
|
+
tag_stack.push(event[1])
|
27
|
+
el = @build_context = @build_context.add_element( event[1] )
|
28
|
+
event[2].each do |key, value|
|
29
|
+
el.attributes[key]=Hobo::Dryml::Parser::Attribute.new(key,value,self)
|
30
|
+
end
|
31
|
+
@build_context.start_tag_source = event[3]
|
32
|
+
@build_context.source_offset = event[4]
|
33
|
+
when :end_element
|
34
|
+
tag_stack.pop
|
35
|
+
@build_context.has_end_tag = event[2]
|
36
|
+
@build_context = @build_context.parent
|
37
|
+
when :text
|
38
|
+
if not in_doctype
|
39
|
+
if @build_context[-1].instance_of? Text
|
40
|
+
@build_context[-1] << event[1]
|
41
|
+
else
|
42
|
+
@build_context.add(
|
43
|
+
Hobo::Dryml::Parser::Text.new(event[1], @build_context.whitespace, nil, true)
|
44
|
+
) unless (
|
45
|
+
@build_context.ignore_whitespace_nodes and
|
46
|
+
event[1].strip.size==0
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
when :comment
|
51
|
+
c = REXML::Comment.new( event[1] )
|
52
|
+
@build_context.add( c )
|
53
|
+
when :cdata
|
54
|
+
c = REXML::CData.new( event[1] )
|
55
|
+
@build_context.add( c )
|
56
|
+
when :processing_instruction
|
57
|
+
@build_context.add( Instruction.new( event[1], event[2] ) )
|
58
|
+
end
|
59
|
+
end
|
60
|
+
rescue REXML::Validation::ValidationException
|
61
|
+
raise
|
62
|
+
rescue
|
63
|
+
raise REXML::ParseException.new( $!.message, @parser.source, @parser, $! )
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -7,14 +7,12 @@ module Hobo::Dryml
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def [](key)
|
10
|
-
|
11
|
-
return s[key] if s.has_key?(key)
|
12
|
-
end
|
13
|
-
nil
|
10
|
+
s = scope_with_key(key) and s[key]
|
14
11
|
end
|
15
12
|
|
16
13
|
def []=(key, val)
|
17
|
-
@scopes.last
|
14
|
+
s = scope_with_key(key) || @scopes.last
|
15
|
+
s[key] = val
|
18
16
|
end
|
19
17
|
|
20
18
|
def new_scope
|
@@ -24,6 +22,13 @@ module Hobo::Dryml
|
|
24
22
|
res
|
25
23
|
end
|
26
24
|
|
25
|
+
def scope_with_key(key)
|
26
|
+
@scopes.reverse_each do |s|
|
27
|
+
return s if s.has_key?(key)
|
28
|
+
end
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
27
32
|
def method_missing(name, *args)
|
28
33
|
if name.to_s =~ /=$/
|
29
34
|
self[name.to_s[0..-2].to_sym] = args.first
|
@@ -19,6 +19,8 @@ module Hobo::Dryml
|
|
19
19
|
if unless repeat
|
20
20
|
part part-locals
|
21
21
|
restore)
|
22
|
+
|
23
|
+
VALID_PARAMETER_TAG_ATTRIBUTES = %w(param replace)
|
22
24
|
|
23
25
|
@build_cache = {}
|
24
26
|
|
@@ -99,7 +101,7 @@ module Hobo::Dryml
|
|
99
101
|
|
100
102
|
@xmlsrc = "<dryml_page>" + src + "</dryml_page>"
|
101
103
|
begin
|
102
|
-
@doc =
|
104
|
+
@doc = Hobo::Dryml::Parser::Document.new(Hobo::Dryml::Parser::Source.new(@xmlsrc))
|
103
105
|
rescue REXML::ParseException => e
|
104
106
|
raise DrymlSyntaxError, "File: #{@template_path}\n#{e}"
|
105
107
|
end
|
@@ -253,7 +255,9 @@ module Hobo::Dryml
|
|
253
255
|
if (for_type = el.attributes['for'])
|
254
256
|
type_name = if defined?(HoboFields) && for_type =~ /^[a-z]/
|
255
257
|
# It's a symbolic type name - look up the Ruby type name
|
256
|
-
HoboFields.to_class(for_type)
|
258
|
+
klass = HoboFields.to_class(for_type)
|
259
|
+
dryml_exception("No such type in polymorphic tag definition: '#{for_type}'", el) unless klass
|
260
|
+
klass.name
|
257
261
|
elsif for_type =~ /^_.*_$/
|
258
262
|
rename_class(for_type)
|
259
263
|
else
|
@@ -581,50 +585,51 @@ module Hobo::Dryml
|
|
581
585
|
|
582
586
|
|
583
587
|
def parameter_tag_hash_item(el, metadata_name)
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
":#{ruby_name el.name} => merge_tag_parameter(#{param_proc(el, metadata_name)}, all_parameters[:#{param_name}])"
|
588
|
+
name = el.name.dup
|
589
|
+
if name.sub!(/^before-/, "")
|
590
|
+
before_parameter_tag_hash_item(name, el, metadata_name)
|
591
|
+
elsif name.sub!(/^after-/, "")
|
592
|
+
after_parameter_tag_hash_item(name, el, metadata_name)
|
593
|
+
elsif name.sub!(/^prepend-/, "")
|
594
|
+
prepend_parameter_tag_hash_item(name, el, metadata_name)
|
595
|
+
elsif name.sub!(/^append-/, "")
|
596
|
+
append_parameter_tag_hash_item(name, el, metadata_name)
|
594
597
|
else
|
595
|
-
|
598
|
+
hash_key = ruby_name name
|
599
|
+
hash_key += "_replacement" if el.attribute("replace")
|
600
|
+
if (param_name = get_param_name(el))
|
601
|
+
":#{hash_key} => merge_tag_parameter(#{param_proc(el, metadata_name)}, all_parameters[:#{param_name}])"
|
602
|
+
else
|
603
|
+
":#{hash_key} => #{param_proc(el, metadata_name)}"
|
604
|
+
end
|
596
605
|
end
|
597
606
|
end
|
598
607
|
|
599
608
|
|
600
|
-
def before_parameter_tag_hash_item(el, metadata_name)
|
609
|
+
def before_parameter_tag_hash_item(name, el, metadata_name)
|
601
610
|
param_name = get_param_name(el)
|
602
611
|
dryml_exception("param declaration not allowed on 'before' parameters", el) if param_name
|
603
|
-
name = el.name.sub(/^before-/, "")
|
604
612
|
content = children_to_erb(el) + "<% _output(#{param_restore_local_name(name)}.call({}, {})) %>"
|
605
|
-
":#{ruby_name name} => #{replace_parameter_proc(el, metadata_name, content)}"
|
613
|
+
":#{ruby_name name}_replacement => #{replace_parameter_proc(el, metadata_name, content)}"
|
606
614
|
end
|
607
615
|
|
608
616
|
|
609
|
-
def after_parameter_tag_hash_item(el, metadata_name)
|
617
|
+
def after_parameter_tag_hash_item(name, el, metadata_name)
|
610
618
|
param_name = get_param_name(el)
|
611
619
|
dryml_exception("param declaration not allowed on 'after' parameters", el) if param_name
|
612
|
-
name = el.name.sub(/^after-/, "")
|
613
620
|
content = "<% _output(#{param_restore_local_name(name)}.call({}, {})) %>" + children_to_erb(el)
|
614
|
-
":#{ruby_name name} => #{replace_parameter_proc(el, metadata_name, content)}"
|
621
|
+
":#{ruby_name name}_replacement => #{replace_parameter_proc(el, metadata_name, content)}"
|
615
622
|
end
|
616
623
|
|
617
624
|
|
618
|
-
def append_parameter_tag_hash_item(el, metadata_name)
|
619
|
-
name = el.name.sub(/^append-/, "")
|
625
|
+
def append_parameter_tag_hash_item(name, el, metadata_name)
|
620
626
|
":#{ruby_name name} => proc { [{}, { :default => proc { |#{param_content_local_name(name)}| new_context { %>" +
|
621
627
|
param_content_element(name) + children_to_erb(el) +
|
622
628
|
"<% } } } ] }"
|
623
629
|
end
|
624
630
|
|
625
631
|
|
626
|
-
def prepend_parameter_tag_hash_item(el, metadata_name)
|
627
|
-
name = el.name.sub(/^prepend-/, "")
|
632
|
+
def prepend_parameter_tag_hash_item(name, el, metadata_name)
|
628
633
|
":#{ruby_name name} => proc { [{}, { :default => proc { |#{param_content_local_name(name)}| new_context { %>" +
|
629
634
|
children_to_erb(el) + param_content_element(name) +
|
630
635
|
"<% } } } ] }"
|
@@ -660,8 +665,14 @@ module Hobo::Dryml
|
|
660
665
|
|
661
666
|
replace_parameter_proc(el, metadata_name)
|
662
667
|
else
|
663
|
-
attributes = el.attributes.map do
|
664
|
-
|
668
|
+
attributes = el.attributes.map do |name, value|
|
669
|
+
if name.in?(VALID_PARAMETER_TAG_ATTRIBUTES)
|
670
|
+
# just ignore
|
671
|
+
elsif name.in?(SPECIAL_ATTRIBUTES)
|
672
|
+
dryml_exception("attribute '#{name}' is not allowed on parameter tags (<#{el.name}:>)", el)
|
673
|
+
else
|
674
|
+
":#{ruby_name name} => #{attribute_to_ruby(value, el)}"
|
675
|
+
end
|
665
676
|
end.compact
|
666
677
|
|
667
678
|
nested_parameters_hash = parameter_tags_hash(el, metadata_name)
|
@@ -693,6 +704,11 @@ module Hobo::Dryml
|
|
693
704
|
end
|
694
705
|
|
695
706
|
|
707
|
+
def field_shorthand_element?(el)
|
708
|
+
el.expanded_name =~ /:./
|
709
|
+
end
|
710
|
+
|
711
|
+
|
696
712
|
def tag_attributes(el)
|
697
713
|
attributes = el.attributes
|
698
714
|
items = attributes.map do |n,v|
|
@@ -704,7 +720,7 @@ module Hobo::Dryml
|
|
704
720
|
end.compact
|
705
721
|
|
706
722
|
# if there's a ':' el.name is just the part after the ':'
|
707
|
-
items << ":field => \"#{ruby_name el.name}\"" if el
|
723
|
+
items << ":field => \"#{ruby_name el.name}\"" if field_shorthand_element?(el)
|
708
724
|
|
709
725
|
items = items.join(", ")
|
710
726
|
|
@@ -765,7 +781,7 @@ module Hobo::Dryml
|
|
765
781
|
|
766
782
|
|
767
783
|
def static_element_to_erb(el)
|
768
|
-
if
|
784
|
+
if promote_static_tag_to_method_call?(el)
|
769
785
|
static_tag_to_method_call(el)
|
770
786
|
else
|
771
787
|
start_tag_src = el.start_tag_source.gsub(REXML::CData::START, "").gsub(REXML::CData::STOP, "")
|
@@ -784,6 +800,11 @@ module Hobo::Dryml
|
|
784
800
|
end
|
785
801
|
|
786
802
|
|
803
|
+
def promote_static_tag_to_method_call?(el)
|
804
|
+
%w(part merge-attrs if unless repeat).any? {|x| el.attributes[x]}
|
805
|
+
end
|
806
|
+
|
807
|
+
|
787
808
|
def apply_control_attributes(expression, el)
|
788
809
|
controls = %w(if unless repeat).map_hash { |x| el.attributes[x] }.compact
|
789
810
|
|
@@ -49,14 +49,17 @@ module Hobo::Dryml
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
attr_accessor
|
53
52
|
|
54
53
|
for attr in [:erb_binding, :part_contexts, :view_name,
|
55
|
-
:this, :this_parent, :this_field,
|
54
|
+
:this, :this_parent, :this_field, :this_key,
|
56
55
|
:form_field_path, :form_this, :form_field_names]
|
57
56
|
class_eval "def #{attr}; @_#{attr}; end"
|
58
57
|
end
|
59
58
|
|
59
|
+
def this_key=(key)
|
60
|
+
@_this_key = key
|
61
|
+
end
|
62
|
+
|
60
63
|
|
61
64
|
# The type of this, or when this is nil, the type that would be expected in the current field
|
62
65
|
def this_type
|
@@ -87,7 +90,8 @@ module Hobo::Dryml
|
|
87
90
|
|
88
91
|
|
89
92
|
def this_field_reflection
|
90
|
-
|
93
|
+
this.try.proxy_reflection ||
|
94
|
+
(this_parent && this_field && this_parent.class.respond_to?(:reflections) && this_parent.class.reflections[this_field.to_sym])
|
91
95
|
end
|
92
96
|
|
93
97
|
|
@@ -179,15 +183,17 @@ module Hobo::Dryml
|
|
179
183
|
|
180
184
|
|
181
185
|
def find_polymorphic_tag(name, call_type=nil)
|
182
|
-
call_type ||= (this.is_a?(Array) && this.respond_to?(:member_class) && this.
|
186
|
+
call_type ||= (this.is_a?(Array) && this.respond_to?(:member_class) && this.member_class) || this_type
|
183
187
|
|
184
188
|
while true
|
185
|
-
if
|
186
|
-
return name
|
187
|
-
elsif respond_to?(poly_name = "#{name}__for_#{call_type.name.to_s.underscore.gsub('/', '__')}")
|
189
|
+
if respond_to?(poly_name = "#{name}__for_#{call_type.name.to_s.underscore.gsub('/', '__')}")
|
188
190
|
return poly_name
|
189
191
|
else
|
190
|
-
call_type
|
192
|
+
if call_type == ActiveRecord::Base || call_type == Object
|
193
|
+
return name
|
194
|
+
else
|
195
|
+
call_type = call_type.superclass
|
196
|
+
end
|
191
197
|
end
|
192
198
|
end
|
193
199
|
end
|
@@ -315,13 +321,14 @@ module Hobo::Dryml
|
|
315
321
|
|
316
322
|
def call_tag_parameter(the_tag, attributes, parameters, caller_parameters, param_name)
|
317
323
|
overriding_proc = caller_parameters[param_name]
|
324
|
+
replacing_proc = caller_parameters[:"#{param_name}_replacement"]
|
318
325
|
|
319
326
|
if param_name == :default && overriding_proc
|
320
327
|
# :default content is handled specially
|
321
328
|
|
322
329
|
call_tag_parameter_with_default_content(the_tag, attributes, parameters[:default], overriding_proc)
|
323
|
-
|
324
|
-
elsif
|
330
|
+
|
331
|
+
elsif replacing_proc
|
325
332
|
# The caller is replacing this parameter. Don't call the tag
|
326
333
|
# at all, just the overriding proc, but pass the restorable
|
327
334
|
# tag as a parameter to the overriding proc
|
@@ -330,9 +337,17 @@ module Hobo::Dryml
|
|
330
337
|
# Call the replaced tag with the attributes and parameters
|
331
338
|
# as given in the original tag definition, and with the
|
332
339
|
# specialisation given on the 'restore' call
|
340
|
+
|
341
|
+
if overriding_proc
|
342
|
+
overriding_attributes, overriding_parameters = overriding_proc.call
|
343
|
+
restore_attrs = overriding_attributes.merge(restore_attrs)
|
344
|
+
restore_params = overriding_parameters.merge(restore_params)
|
345
|
+
end
|
346
|
+
|
333
347
|
override_and_call_tag(the_tag, attributes, parameters, restore_attrs, restore_params)
|
334
348
|
end
|
335
|
-
|
349
|
+
replacing_proc.call(tag_restore)
|
350
|
+
|
336
351
|
|
337
352
|
else
|
338
353
|
overriding_attributes, overriding_parameters = overriding_proc._?.call
|
@@ -423,7 +438,7 @@ module Hobo::Dryml
|
|
423
438
|
end
|
424
439
|
|
425
440
|
|
426
|
-
def
|
441
|
+
def part_contexts_javascripts
|
427
442
|
storage = part_contexts_storage
|
428
443
|
storage.blank? ? "" : "<script>\n#{storage}</script>\n"
|
429
444
|
end
|
@@ -437,7 +452,7 @@ module Hobo::Dryml
|
|
437
452
|
def render_tag(tag_name, attributes)
|
438
453
|
method_name = tag_name.gsub('-', '_')
|
439
454
|
if respond_to?(method_name)
|
440
|
-
res = (send(method_name, attributes) +
|
455
|
+
res = (send(method_name, attributes) + part_contexts_javascripts).strip
|
441
456
|
|
442
457
|
# TODO: Temporary hack to get the dryml metadata comments in the right place
|
443
458
|
if RAILS_ENV == "development"
|