dryml 1.3.0.RC4 → 1.3.0.pre10

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,17 +2,22 @@ require 'rake'
2
2
  require 'rake/rdoctask'
3
3
  require 'rake/testtask'
4
4
 
5
+ $:.unshift File.expand_path('../lib', __FILE__)
6
+ $:.unshift File.expand_path('../../hobo_support/lib', __FILE__)
7
+ require 'dryml' # to get VERSION
8
+
5
9
  RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
6
10
  RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
7
11
 
12
+ desc "Default Task"
13
+ task :default => [ :test ]
14
+
8
15
  # --- Testing --- #
9
16
 
10
- namespace "test" do
11
- desc "Run the doctests"
12
- task :doctest do |t|
13
- files=Dir['test/**/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
14
- exit(1) if !system("#{RUBYDOCTEST} #{files}")
15
- end
17
+ desc "Run all tests"
18
+ task :test do |t|
19
+ files=Dir['test/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
20
+ exit(1) if !system("#{RUBYDOCTEST} #{files}")
16
21
  end
17
22
 
18
23
  # --- RDOC --- #
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.RC4
1
+ 1.3.0.pre10
data/dryml.gemspec CHANGED
@@ -1,6 +1,5 @@
1
1
  name = File.basename( __FILE__, '.gemspec' )
2
2
  version = File.read(File.expand_path('../VERSION', __FILE__)).strip
3
- require 'date'
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
 
@@ -11,7 +10,7 @@ Gem::Specification.new do |s|
11
10
  s.summary = "The Don't Repeat Yourself Markup Language"
12
11
  s.description = "The Don't Repeat Yourself Markup Language"
13
12
 
14
- s.add_runtime_dependency('actionpack', ["~> 3.0.0"])
13
+ s.add_runtime_dependency('actionpack', [">= 3.0.0"])
15
14
  s.add_runtime_dependency('hobo_support', ["= #{version}"])
16
15
  s.add_development_dependency('rubydoctest', [">= 0"])
17
16
 
@@ -25,5 +24,4 @@ Gem::Specification.new do |s|
25
24
  s.rdoc_options = ["--charset=UTF-8"]
26
25
  s.require_paths = ["lib"]
27
26
 
28
- s.extensions = 'ext/mkrf_conf.rb'
29
27
  end
@@ -1,5 +1,3 @@
1
- require 'erubis'
2
-
3
1
  module Dryml
4
2
 
5
3
  class DRYMLBuilder
@@ -60,49 +58,10 @@ module Dryml
60
58
  end
61
59
 
62
60
 
63
- class Erubis < ::Erubis::Eruby
64
- def add_preamble(src)
65
-
66
- end
67
-
68
- def add_text(src, text)
69
- return if text.empty?
70
- src << "self.output_buffer.safe_concat('" << escape_text(text) << "');"
71
- end
72
-
73
- BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/
74
-
75
- def add_expr_literal(src, code)
76
- if code =~ BLOCK_EXPR
77
- src << 'self.output_buffer.append= ' << code << ";\nself.output_buffer;"
78
- else
79
- src << 'self.output_buffer.append= (' << code << ");\nself.output_buffer;"
80
- end
81
- end
82
-
83
- def add_stmt(src, code)
84
- # skip fallback code - it utterly destroys DRYML-generated ERB
85
- super
86
- end
87
-
88
- def add_expr_escaped(src, code)
89
- if code =~ BLOCK_EXPR
90
- src << "self.output_buffer.safe_append= " << code << ";\nself.output_buffer;"
91
- else
92
- src << "self.output_buffer.safe_concat((" << code << ").to_s);"
93
- end
94
- end
95
-
96
- def add_postamble(src)
97
- # NOTE: we can't just add a 'self.output_buffer' here because this parser
98
- # is used to compile taglibs which don't HAVE one
99
- end
100
- end
101
-
102
61
  def erb_process(erb_src)
103
62
  trim_mode = ActionView::TemplateHandlers::ERB.erb_trim_mode
104
- erb = Erubis.new(erb_src, :trim_mode => trim_mode)
105
- res = erb.src
63
+ erb = ERB.new(erb_src, nil, trim_mode, "output_buffer")
64
+ res = erb.src.split(';')[1..-2].join(';')
106
65
  if res.respond_to? :force_encoding
107
66
  res.force_encoding(erb_src.encoding)
108
67
  end
@@ -32,21 +32,15 @@ require 'rexml/xpath'
32
32
 
33
33
  def initialize(home, filename, name=nil)
34
34
  @name = name || filename.sub(/.dryml$/, '')[home.length+1..-1]
35
- @source = File.read(filename)
36
35
  @doc = Dryml::Parser::Document.new(File.read(filename), filename)
37
36
  parse_tag_defs
38
37
  end
39
38
 
40
- attr_reader :name, :doc, :tag_defs, :source
39
+ attr_reader :name, :doc, :tag_defs
41
40
 
42
41
  def comment
43
42
  first_node = doc[0][0]
44
- if first_node.is_a?(REXML::Comment)
45
- doc.restore_erb_scriptlets(first_node.to_s.strip)
46
- elsif first_node.to_s.strip.starts_with?("[![DRYML-ERB")
47
- text = doc.restore_erb_scriptlets(first_node.to_s.strip)
48
- text.match(/<%#(.*?)%>/m)[1] rescue nil
49
- end
43
+ doc.restore_erb_scriptlets(first_node.to_s.strip) if first_node.is_a?(REXML::Comment)
50
44
  end
51
45
 
52
46
  include CommentMethods
@@ -83,7 +77,7 @@ require 'rexml/xpath'
83
77
  doc.restore_erb_scriptlets(node.to_s).strip
84
78
  end
85
79
 
86
- # The contents of the XML or ERB comment, if any, immediately above the tag definition
80
+ # The contents of the XML comment, if any, immediately above the tag definition
87
81
  def comment
88
82
  @comment ||= begin
89
83
  space = node.previous_sibling and
@@ -92,9 +86,6 @@ require 'rexml/xpath'
92
86
 
93
87
  if comment_node.is_a?(REXML::Comment)
94
88
  doc.restore_erb_scriptlets(comment_node.to_s.strip)
95
- elsif space.to_s.strip.starts_with?("[![DRYML-ERB")
96
- text = doc.restore_erb_scriptlets(space.to_s.strip)
97
- text.match(/.*<%#(.*?)%>$/m)[1] rescue nil
98
89
  end
99
90
  end
100
91
  end
@@ -195,7 +195,6 @@ require 'fileutils'
195
195
  refl = model.reflections[collection]
196
196
  klass = refl.klass
197
197
  klass < ActiveRecord::Acts::List::InstanceMethods &&
198
- klass.table_exists? &&
199
198
  klass.new.position_column == refl.options[:order].to_s
200
199
  end
201
200
  end
@@ -4,12 +4,19 @@ ActionController::Base.class_eval do
4
4
  append_view_path Dryml::Railtie::PageTagResolver.new(self)
5
5
  end
6
6
 
7
- attr_accessor :dryml_fallback_tag
7
+ # dryml does not use layouts
8
+ def action_has_layout?
9
+ false
10
+ end
8
11
 
9
12
  def dryml_context
10
13
  @this
11
14
  end
12
15
 
16
+ def dryml_fallback_tag(tag_name)
17
+ @dryml_fallback_tag = tag_name
18
+ end
19
+
13
20
  def call_dryml_tag(tag, options={})
14
21
  # TODO: Figure out what this bit is all about :-)
15
22
  if options[:with]
data/lib/dryml/helper.rb CHANGED
@@ -31,7 +31,7 @@ module Dryml::Helper
31
31
  end
32
32
  res
33
33
  end
34
-
34
+
35
35
  def first_item?
36
36
  if scope.repeat_collection.respond_to? :each_pair
37
37
  this == scope.repeat_collection.first.try.last
@@ -39,8 +39,8 @@ module Dryml::Helper
39
39
  this == scope.repeat_collection.first
40
40
  end
41
41
  end
42
-
43
-
42
+
43
+
44
44
  def last_item?
45
45
  if scope.repeat_collection.respond_to? :each_pair
46
46
  this == scope.repeat_collection.last.try.last
@@ -49,7 +49,7 @@ module Dryml::Helper
49
49
  end
50
50
  end
51
51
 
52
- def param_name_for(path)
52
+ def param_name_for(path)
53
53
  field_path = field_path.to_s.split(".") if field_path.is_one_of?(String, Symbol)
54
54
  attrs = path.rest.map{|part| "[#{part.to_s.sub /\?$/, ''}]"}.join
55
55
  "#{path.first}#{attrs}"
@@ -21,8 +21,8 @@
21
21
  "hoboParts['#{dom_id}'] = (#{code});\n"
22
22
  end.join
23
23
  end
24
-
25
-
24
+
25
+
26
26
  def self.pre_marshal(x)
27
27
  if x.is_a?(ActiveRecord::Base) && x.respond_to?(:typed_id)
28
28
  TypedId.new(x.typed_id)
@@ -40,19 +40,19 @@
40
40
  c.form_field_path = environment.form_field_path
41
41
  end
42
42
  end
43
-
44
-
43
+
44
+
45
45
  def self.for_refresh(encoded_context, page_this, session)
46
46
  new do |c|
47
47
  c.unmarshal(encoded_context, page_this, session)
48
48
  end
49
49
  end
50
-
51
-
50
+
51
+
52
52
  def initialize
53
53
  yield self
54
54
  end
55
-
55
+
56
56
  attr_accessor :part_name, :locals, :this, :this_field, :this_id, :form_field_path
57
57
 
58
58
 
@@ -72,20 +72,20 @@
72
72
  raise TamperedWithPartContext unless digest == generate_digest(data, session)
73
73
 
74
74
  context = Marshal.load(Base64.decode64(data))
75
-
75
+
76
76
  part_name, this_id, locals, form_field_path = context
77
77
 
78
78
  if RAILS_DEFAULT_LOGGER
79
79
  RAILS_DEFAULT_LOGGER.info "Call part: #{part_name}. this-id = #{this_id}, locals = #{locals.inspect}"
80
80
  RAILS_DEFAULT_LOGGER.info " : form_field_path = #{form_field_path.inspect}" if form_field_path
81
81
  end
82
-
82
+
83
83
  self.part_name = part_name
84
84
  self.this_id = this_id
85
85
  self.locals = restore_locals(locals)
86
86
  self.form_field_path = form_field_path
87
-
88
- parse_this_id(page_this)
87
+
88
+ parse_this_id(page_this)
89
89
  end
90
90
 
91
91
 
@@ -121,7 +121,7 @@
121
121
  def restore_locals(locals)
122
122
  locals.map do |l|
123
123
  if l.is_a?(TypedId)
124
- Hobo::Model.find_by_typed_id(l)
124
+ Hobo::Model.find_by_typed_id(this_id)
125
125
  else
126
126
  l
127
127
  end
@@ -0,0 +1,13 @@
1
+ module Dryml
2
+ class Railtie
3
+ class PageTagHandler < ActionView::Template::Handler
4
+
5
+ self.default_format = Mime::HTML
6
+
7
+ def self.call(template)
8
+ "ActionView::Template::Text.new(%q(#{template.source}), Mime::HTML).render"
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -8,16 +8,12 @@ module Dryml
8
8
  end
9
9
 
10
10
  def find_templates(name, prefix, partial, details)
11
- tag_name = @controller.dryml_fallback_tag || name.dasherize + '-page'
12
- method_name = tag_name.to_s.gsub('-', '_')
13
- if Dryml.empty_page_renderer(@controller.view_context).respond_to?(method_name)
14
- [ActionView::Template.new('', Dryml.page_tag_identifier(@controller.controller_path, tag_name),
15
- Dryml::Railtie::TemplateHandler, details)]
16
- else
17
- []
18
- end
11
+ tag_name = @dryml_fallback_tag || name.dasherize + '-page'
12
+ text = @controller.call_dryml_tag(tag_name)
13
+ return [] unless text
14
+ [ActionView::Template.new(text, "dryml-tag:#{tag_name}", Dryml::Railtie::PageTagHandler, details)]
19
15
  end
20
16
 
21
- end
17
+ end
22
18
  end
23
19
  end
data/lib/dryml/railtie.rb CHANGED
@@ -15,12 +15,5 @@ module Dryml
15
15
  ActionView::Template.register_template_handler("dryml", Dryml::Railtie::TemplateHandler)
16
16
  end
17
17
 
18
- initializer 'dryml' do |app|
19
- app.config.to_prepare do
20
- Dryml.clear_cache
21
- Dryml::Taglib.clear_cache
22
- end
23
- end
24
-
25
18
  end
26
19
  end
@@ -22,7 +22,7 @@
22
22
 
23
23
  undef_method :default
24
24
 
25
- # Question: does this do anything? -Tom
25
+ # Question: does this do anything? -Tom
26
26
  def [](param_name)
27
27
  fetch(param_name, nil)
28
28
  end
data/lib/dryml/taglib.rb CHANGED
@@ -24,40 +24,27 @@
24
24
 
25
25
  private
26
26
 
27
- # Requirements for hobo-plugin for loading a taglib when the plugin is loaded as a gem:
28
- # - the plugin must define the <gem_name>.camelize.constantize.root() method
29
- # - the root() method must return a Pathname object (like Hobo.root, Dryml.root, Rails.root, etc.)
30
- # - the taglibs must be available in the 'taglibs' dir in the gem root
31
- # You can include the taglib with <include gem='gem_name'/> if the taglib name has the same gem name.
32
- # If the plugin defines different taglibs you must also specify the src attribute of the taglib that you want
33
- # to include: <include gem='gem_name' src='taglib_name'/>'
34
-
35
27
  def taglib_filename(options)
36
- plugin = options[:plugin]
37
- gem = options[:gem]
38
- app_root = Object.const_defined?(:Rails) ? Rails.root : Pathname.new(File.expand_path('.'))
39
- taglibs_path = case
40
- when plugin == 'dryml'
41
- Dryml.root.join 'taglibs'
42
- when plugin == 'hobo', gem == 'hobo'
43
- Hobo.root.join 'lib/hobo/rapid/taglibs'
44
- when !plugin.blank?
45
- app_root.join 'vendor/plugins', plugin, 'taglibs'
46
- when !gem.blank?
47
- gem.tr('-','_').camelize.constantize.root.join 'taglibs'
48
- when options[:src] =~ /\//
49
- app_root.join 'app/views'
50
- when options[:template_dir] =~ /^#{Hobo.root}/
51
- Pathname.new(options[:template_dir])
52
- when options[:absolute_template_path]
53
- Pathname.new(options[:absolute_template_path])
54
- else
55
- app_root.join options[:template_dir].gsub(/^\//, '') # remove leading / if there is one
56
- end
57
- src = options[:src] || gem || plugin
58
- taglib_file = taglibs_path.join "#{src}.dryml"
59
- raise DrymlException, "No such taglib: #{src} #{options.inspect} #{taglib_file}" unless taglib_file.exist?
60
- taglib_file.to_s
28
+ plugin = options[:plugin]
29
+ rails_root = Object.const_defined?(:Rails) ? Rails.root : "."
30
+ base = if plugin == "dryml"
31
+ "#{Dryml.root}/taglibs"
32
+ elsif plugin == "hobo"
33
+ "#{Hobo.root}/lib/hobo/rapid/taglibs"
34
+ elsif options[:src] =~ /\//
35
+ "#{rails_root}/app/views"
36
+ elsif options[:template_dir] =~ /^#{Hobo.root}/
37
+ options[:template_dir]
38
+ elsif options[:absolute_template_path]
39
+ options[:absolute_template_path]
40
+ else
41
+ "#{rails_root}/#{options[:template_dir].gsub(/^\//, '')}" # remove leading / if there is one
42
+ end
43
+
44
+ src = options[:src] || plugin
45
+ filename = "#{base}/#{src}.dryml"
46
+ raise DrymlException, "No such taglib: #{base} #{options.inspect} #{filename}" unless File.exists?(filename)
47
+ filename
61
48
  end
62
49
 
63
50
  end
@@ -51,7 +51,7 @@ module Dryml
51
51
  def compile(local_names=[], auto_taglibs=[])
52
52
  now = Time.now
53
53
 
54
- unless @template_path.blank?
54
+ unless @template_path.ends_with?(EMPTY_PAGE)
55
55
  p = Pathname.new template_path
56
56
  p = Pathname.new(Rails.root) + p unless p.absolute? || !Object.const_defined?(:Rails)
57
57
  mtime = p.mtime rescue Time.now
@@ -133,7 +133,6 @@ module Dryml
133
133
  when scriplet_rex
134
134
  t
135
135
  when /\S+/
136
- t.gsub!(/(\(|\))/){"\\#{$1}"}
137
136
  "<% safe_concat %(#{t}) %>"
138
137
  else
139
138
  t
@@ -190,7 +189,7 @@ module Dryml
190
189
  require_toplevel(el)
191
190
  require_attribute(el, "as", /^#{DRYML_NAME}$/, true)
192
191
  options = {}
193
- %w(src module plugin gem as).each do |attr|
192
+ %w(src module plugin as).each do |attr|
194
193
  options[attr.to_sym] = el.attributes[attr] if el.attributes[attr]
195
194
  end
196
195
  @builder.add_build_instruction(:include, options)
@@ -251,11 +250,7 @@ module Dryml
251
250
  _tag_context(attributes) do
252
251
  attributes.delete :with
253
252
  attributes.delete :field
254
- if for_klass = parse_for_type(attributes)
255
- call_polymorphic_tag('#{name}', for_klass, attributes, parameters) { #{name}__base(attributes.except, parameters) }
256
- else
257
- call_polymorphic_tag('#{name}', attributes, parameters) { #{name}__base(attributes.except, parameters) }
258
- end
253
+ call_polymorphic_tag('#{name}', attributes, parameters) { #{name}__base(attributes.except, parameters) }
259
254
  end
260
255
  end
261
256
  )
@@ -276,9 +271,7 @@ module Dryml
276
271
  # It's a symbolic type name - look up the Ruby type name
277
272
  klass = HoboFields.to_class(for_type) or
278
273
  dryml_exception("No such type in polymorphic tag definition: '#{for_type}'", el)
279
- # ActiveSupport::TimeWithZone.name would return 'Time'
280
- # so we add an exception to pick the right datetime type
281
- klass == ActiveSupport::TimeWithZone ? 'datetime' : klass.name
274
+ klass.name
282
275
  else
283
276
  for_type
284
277
  end.underscore.gsub('/', '__')
@@ -402,17 +395,17 @@ module Dryml
402
395
  "<% output_buffer; end"
403
396
  end
404
397
 
398
+
405
399
  def wrap_source_with_metadata(content, kind, name, *args)
406
400
  if (!include_source_metadata) || name.in?(NO_METADATA_TAGS)
407
401
  content
408
402
  else
409
403
  metadata = [kind, name] + args + [@template_path]
410
- "<% safe_concat(%(<!--[DRYML|#{metadata * '|'}[-->)) %>" +
411
- content +
412
- "<% safe_concat(%(<!--]DRYML]-->)) %>"
404
+ "<!--[DRYML|#{metadata * '|'}[-->" + content + "<!--]DRYML]-->"
413
405
  end
414
406
  end
415
407
 
408
+
416
409
  def wrap_tag_method_body_with_metadata(content)
417
410
  name = @def_element.attributes['tag']
418
411
  for_ = @def_element.attributes['for']
@@ -554,7 +547,7 @@ module Dryml
554
547
  'this_type'
555
548
  elsif t =~ /^[A-Z]/
556
549
  t
557
- elsif t =~ /^[a-z]/ && defined?(HoboFields.to_class)
550
+ elsif t =~ /^[a-z]/ && defined? HoboFields.to_class
558
551
  klass = HoboFields.to_class(t)
559
552
  klass.name
560
553
  elsif is_code_attribute?(t)
@@ -726,14 +719,14 @@ module Dryml
726
719
  def append_parameter_tag_hash_item(name, el, metadata_name)
727
720
  ":#{ruby_name name} => proc { [{}, { :default => proc { |#{param_content_local_name(name)}| new_context { %>" +
728
721
  param_content_element(name) + children_to_erb(el) +
729
- "<% ; output_buffer } } } ] }"
722
+ "<% } } } ] }"
730
723
  end
731
724
 
732
725
 
733
726
  def prepend_parameter_tag_hash_item(name, el, metadata_name)
734
727
  ":#{ruby_name name} => proc { [{}, { :default => proc { |#{param_content_local_name(name)}| new_context { %>" +
735
728
  children_to_erb(el) + param_content_element(name) +
736
- "<% ; output_buffer } } } ] }"
729
+ "<% } } } ] }"
737
730
  end
738
731
 
739
732
 
@@ -741,7 +734,7 @@ module Dryml
741
734
  content = children_to_erb(el)
742
735
  content = wrap_source_with_metadata(content, "param", containing_param_name,
743
736
  element_line_num(el)) if containing_param_name
744
- "proc { |#{param_content_local_name(el.dryml_name)}| new_context { %>#{content}<% ; output_buffer } #{tag_newlines(el)}}"
737
+ "proc { |#{param_content_local_name(el.dryml_name)}| new_context { %>#{content}<% } #{tag_newlines(el)}}"
745
738
  end
746
739
 
747
740
 
@@ -755,8 +748,8 @@ module Dryml
755
748
  end
756
749
 
757
750
 
758
- def param_proc(el, metadata_name_suffix)
759
- metadata_name = "#{el.name} < #{metadata_name_suffix}"
751
+ def param_proc(el, metadata_name_prefix)
752
+ metadata_name = "#{metadata_name_prefix}><#{el.name}"
760
753
 
761
754
  nl = tag_newlines(el)
762
755
 
@@ -789,7 +782,7 @@ module Dryml
789
782
  def replace_parameter_proc(el, metadata_name, content=nil)
790
783
  content ||= wrap_replace_parameter(el, metadata_name)
791
784
  param_name = el.dryml_name.sub(/^(before|after|append|prepend)-/, "")
792
- "proc { |#{param_restore_local_name(param_name)}| new_context { %>#{content}<% ; output_buffer } #{tag_newlines(el)}}"
785
+ "proc { |#{param_restore_local_name(param_name)}| new_context { %>#{content}<% } #{tag_newlines(el)}}"
793
786
  end
794
787
 
795
788
 
@@ -817,7 +810,7 @@ module Dryml
817
810
  items = attributes.map do |n,v|
818
811
  dryml_exception("invalid attribute name '#{n}' (remember to use '-' rather than '_')", el) unless n =~ DRYML_NAME_RX
819
812
 
820
- next if n.in?(SPECIAL_ATTRIBUTES-['for-type']) || n =~ /^without-/
813
+ next if n.in?(SPECIAL_ATTRIBUTES) || n =~ /^without-/
821
814
  next if el.attributes['part'] && n == 'id' # The id is rendered on the <div class="part-wrapper"> instead
822
815
 
823
816
  ":#{ruby_name n} => #{attribute_to_ruby(v)}"
@@ -1030,6 +1023,8 @@ module Dryml
1030
1023
  end
1031
1024
 
1032
1025
  def include_source_metadata
1026
+ # disabled for now -- we're still getting broken rendering with this feature on
1027
+ return false
1033
1028
  @include_source_metadata = Rails.env.development? && !ENV['DRYML_EDITOR'].blank? if @include_source_metadata.nil?
1034
1029
  @include_source_metadata
1035
1030
  end
@@ -26,9 +26,10 @@ module Dryml
26
26
  include ActionView::Helpers
27
27
  include Helper ## FIXME remove
28
28
 
29
- def initialize(view=nil)
30
- unless view.nil?
29
+ def initialize(view_name=nil, view=nil)
30
+ unless view_name.nil? && view.nil?
31
31
  @view = view
32
+ @_view_name = view_name
32
33
  @_erb_binding = binding
33
34
  @_part_contexts = {}
34
35
  @_scoped_variables = ScopedVariables.new
@@ -48,7 +49,7 @@ module Dryml
48
49
  end
49
50
  end
50
51
 
51
- for attr in [:erb_binding, :part_contexts,
52
+ for attr in [:erb_binding, :part_contexts, :view_name,
52
53
  :this, :this_parent, :this_field, :this_key,
53
54
  :form_this, :form_field_path, :form_field_names]
54
55
  class_eval "def #{attr}; @_#{attr}; end"
@@ -188,20 +189,6 @@ module Dryml
188
189
  end
189
190
  end
190
191
 
191
- def parse_for_type(attributes)
192
- t = attributes[:for_type]
193
- if t.nil?
194
- nil
195
- elsif t.is_a?(Class)
196
- t
197
- elsif t =~ /^[A-Z]/
198
- t.constantize
199
- elsif t =~ /^[a-z]/ && defined?(HoboFields.to_class)
200
- HoboFields.to_class(t)
201
- else
202
- nil
203
- end
204
- end
205
192
 
206
193
  def call_polymorphic_tag(name, *args)
207
194
  name = name.to_s.gsub('-', '_')
@@ -219,13 +206,11 @@ module Dryml
219
206
 
220
207
  def find_polymorphic_tag(name, call_type=nil)
221
208
  call_type ||= (this.respond_to?(:member_class) && this.member_class) || this_type
209
+
222
210
  begin
223
211
  found = nil
224
212
  while true
225
- # ActiveSupport::TimeWithZone.name would return 'Time'
226
- # so we add an exception to pick the right datetime type
227
- type_name = ( call_type == ActiveSupport::TimeWithZone ? 'datetime' : call_type.name.to_s).underscore.gsub('/', '__')
228
- if respond_to?(poly_name = "#{name}__for_#{type_name}")
213
+ if respond_to?(poly_name = "#{name}__for_#{call_type.name.to_s.underscore.gsub('/', '__')}")
229
214
  found = poly_name
230
215
  break
231
216
  else
@@ -260,8 +245,7 @@ module Dryml
260
245
  @_form_field_path, @_form_field_paths_by_object ]
261
246
  @_this_type = nil
262
247
  res = nil
263
- outer_res = @view.with_output_buffer { res = yield }
264
- Rails.logger.error("new_context: #{caller.first}") if !outer_res.blank? && outer_res.to_s != res.to_s
248
+ @view.with_output_buffer { res = yield }
265
249
  @_this, @_this_parent, @_this_field, @_this_type, @_form_field_path, @_form_field_paths_by_object = ctx
266
250
  res.to_s
267
251
  end
@@ -347,14 +331,13 @@ module Dryml
347
331
 
348
332
 
349
333
  def with_form_context(form_this=this, form_field_path=[form_this.class.name.underscore])
350
- ctx = [@_form_this, @_form_field_path, @_form_field_paths_by_object]
351
334
  @_form_this = form_this
352
335
  @_form_field_path = form_field_path
353
336
  @_form_field_paths_by_object = { form_this => form_field_path }
354
337
  res = scope.new_scope :in_form => true, :form_field_names => [] do
355
338
  yield
356
339
  end
357
- @_form_this, @_form_field_path, @_form_field_paths_by_object = ctx
340
+ @_form_this = @_form_field_path = @_form_field_paths_by_object = nil
358
341
  res
359
342
  end
360
343
 
@@ -542,6 +525,14 @@ module Dryml
542
525
  end
543
526
 
544
527
 
528
+
529
+
530
+ def part_contexts_javascripts
531
+ storage = part_contexts_storage
532
+ storage.blank? ? "" : "<script type=\"text/javascript\">\n#{storage}</script>\n"
533
+ end
534
+
535
+
545
536
  def part_contexts_storage
546
537
  PartContext.client_side_storage(@_part_contexts, session)
547
538
  end