masterview 0.3.3 → 0.3.4

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 CHANGED
@@ -1,4 +1,11 @@
1
- 0.3.3
1
+ 0.3.4 - October 4th, 2007
2
+ Added rake task mv:generate_all_rhtml which calls mv:parse to generate all the rhtml files. Added to make it clearer for those wanting to generate their rhtml manually.
3
+ Make values in gen_partial and import_partial retain their page specific values, allowing you to specify different locals, collections, or objects for import_render than you do on gen_partial. Also allows you to reuse the partial multiple times on a page with different values. (thanks James Britt)
4
+ Fix rebuild template so that it uses the same list of XHTML empty elements to determine whether to collapse empty elements (thanks Brian Jordan)
5
+ Fixed problem with CruiseControl where ActionController was not defined (thanks James Britt)
6
+
7
+
8
+ 0.3.3 - July 1, 2007
2
9
  Added xml doctype to generated code
3
10
  Fixed bug in gen_replace where it was generating <% %> rather than <%= %> (Thanks to Jon Frisby for indentifying)
4
11
  Fix defect in form tag not setting :multipart => true when form enctype=multipart/form-data (Thanks to Rajavel Lenin for identifying)
data/RELEASE_NOTES CHANGED
@@ -1,4 +1,18 @@
1
1
  = MasterView - Rails-optimized (x)html friendly template engine
2
+ == Recent changes (Release 0.3.4)
3
+ Added mv:generate_all_rhtml rake task which generates all rhtml files to make it
4
+ more obvious for users who want to generate the rhtml files. Also changed the way
5
+ gen_partial and import_render work with regards to collections, object, and locals,
6
+ they now retain the values from the page even after rebuild. This allows you to have
7
+ different values on each page and even different values on the same page if use partials
8
+ multiple times on a page.
9
+
10
+ Make values in gen_partial and import_partial retain their page specific values, allowing you to specify different locals, collections, or objects for import_render than you do on gen_partial. Also allows you to reuse the partial multiple times on a page with different values. (thanks James Britt)
11
+
12
+ Fix rebuild template so that it uses the same list of XHTML empty elements to determine whether to collapse empty elements (thanks to Brian Jordan)
13
+
14
+ Fixed a problem with CruiseControl where ActionController was not defined when masterview was initialized. (thanks James Britt)
15
+
2
16
 
3
17
  == Recent changes (Release 0.3.3) - Maintenance release plus auto_copy
4
18
  Added auto copy feature which can be configured to automatically copy static files
data/Rakefile CHANGED
@@ -643,15 +643,17 @@ task :publish_news => [ :verify_rubyforge] do
643
643
  news.subject = "MasterView #{MasterView::VERSION::STRING} Rails-optimized (x)html template engine"
644
644
  news.changes_file = nil
645
645
 
646
- details = []
647
- File.open("ReleaseAnnouncement") do |file|
648
- file.each do |line|
649
- line.chomp!
650
- break if line =~ /^=/
651
- details << line
652
- end
653
- end
654
- news.details = details.join("\n")
646
+ # details = []
647
+ # File.open("ReleaseAnnouncement") do |file|
648
+ # file.each do |line|
649
+ # line.chomp!
650
+ # break if line =~ /^=/
651
+ # details << line
652
+ # end
653
+ # end
654
+ # news.details = details.join("\n")
655
+
656
+ news.details = File.read("ReleaseAnnouncement")
655
657
  end
656
658
  end
657
659
 
data/ReleaseAnnouncement CHANGED
@@ -1,10 +1,10 @@
1
1
  = MasterView - Rails-optimized (x)html friendly template engine
2
2
 
3
- MasterView is a template engine plugin that provides another option to the existing rails view templates (rhtml and rxml). This template engine has all the power of layouts, partials, and rails helpers but is still editable/styleable in a WYSIWYG editor.
3
+ MasterView is a template engine plugin that provides another option to the existing rails view templates (rhtml and rxml). This template engine has all the power of layouts, partials, and rails helpers but is still editable/styleable in a WYSIWYG editor.
4
4
 
5
- Another major goal it to have the syntax of these attribute directives be very similar to rails helpers so that one could intuitively start using MasterView with little learning curve other than knowing rails. MasterView users can additionally create their own directives to encapsulate custom functionality so the system can be easily extended into specific uses.
5
+ Another major goal it to have the syntax of these attribute directives be very similar to rails helpers so that one could intuitively start using MasterView with little learning curve other than knowing rails. MasterView users can additionally create their own directives to encapsulate custom functionality so the system can be easily extended into specific uses.
6
6
 
7
- MasterView was inspired by Amrita, Kwartz, Tapestry, Zope/PHP TAL, Liquid, and Web Objects but designed with a fresh approach and specifically targetted for rails users.
7
+ MasterView was inspired by Amrita, Kwartz, Tapestry, Zope/PHP TAL, Liquid, and Web Objects but designed with a fresh approach and specifically targetted for rails users.
8
8
 
9
9
  There are several ways to use MasterView:
10
10
 
@@ -14,8 +14,21 @@ There are several ways to use MasterView:
14
14
 
15
15
  - If you already have an application but would like to use MasterView, you can start to use MasterView for new pages. MasterView will co-exist nicely with existing rhtml and you can slowly evolve the site over time.
16
16
 
17
+ == Recent changes (Release 0.3.4)
18
+ Make values in gen_partial and import_partial retain their page specific values, allowing you to specify different locals, collections, or objects for import_render than you do on gen_partial. Also allows you to reuse the partial multiple times on a page with different values. (thanks James Britt)
17
19
 
18
- == Recent changes (Release 0.3.3) - Maintenance release plus auto_copy
20
+ Fix rebuild template so that it uses the same list of XHTML empty elements to determine whether to collapse empty elements (thanks to Brian Jordan)
21
+
22
+ Fixed a problem with CruiseControl where ActionController was not defined when masterview was initialized. (thanks James Britt)
23
+
24
+ Added mv:generate_all_rhtml rake task which generates all rhtml files to make it
25
+ more obvious for users who want to generate the rhtml files. Also changed the way
26
+ gen_partial and import_render work with regards to collections, object, and locals,
27
+ they now retain the values from the page even after rebuild. This allows you to have
28
+ different values on each page and even different values on the same page if use partials
29
+ multiple times on a page.
30
+
31
+ == Recent changes (Release 0.3.3) - Maintenance release plus auto_copy
19
32
  Added auto copy feature which can be configured to automatically copy static files like stylesheets, images, and javascripts from a non-standard location to the proper location at runtime (under Rails public). This makes it easy to use HTML prototypes and associated files with MasterView eliminating any manual copying.
20
33
 
21
34
  This release fix adds doctype to generated code, and a bug in gen_replace which outputted <% %> rather than <%= %> (thanks Jon Frisby). Fixed defect in multipart form and stylesheet_link directives (thanks Rajavel Lenin).
@@ -24,9 +37,9 @@ Made REXML sax2parser configurable. Generator now creates example for custom adm
24
37
 
25
38
  Fix defect which prevented MasterView to be used with Goldberg or other plugins which alter the view base unless MasterView was configured to generate the rhtml files.
26
39
 
27
- Fix rails runtime detection when running in RadRails which launches using -e
40
+ Fix rails runtime detection when running in RadRails which launches using -e
28
41
 
29
- Added rake task mv:clean_mv_rhtml task which removes the MasterView generated rhtml if you have configured MasterView to generate to the file system. Only removes files that it generates leaving other rhtml untouched. This is useful when switching to not generating rhtml mode when it was previously enabled.
42
+ Added rake task mv:clean_mv_rhtml task which removes the MasterView generated rhtml if you have configured MasterView to generate to the file system. Only removes files that it generates leaving other rhtml untouched. This is useful when switching to not generating rhtml mode when it was previously enabled.
30
43
 
31
44
  == Release 0.3.2 - Maintenance release plus custom admin auth
32
45
  This release addresses a compatibility problem with Rails 1.2 where a view syntax error would not display the normal debug output but instead displayed only a blank screen. Also fixed a parsing problem with multiple parameters in some directives. Added the ability to use custom mixin for authorization to MasterView admin screens. Changed the MasterView generator to use request, flash, and params rather than deprecated @request, @flash, and @params. Tested with Rails 1.2.2
@@ -76,13 +89,13 @@ Requires::
76
89
  No external dependencies
77
90
 
78
91
  Optional::
79
- tidy (gem) and tidy library
80
- if these are installed you can use tidy to cleanup
92
+ tidy (gem) and tidy library
93
+ if these are installed you can use tidy to cleanup
81
94
  html into valid xhtml for use by MasterView
82
95
 
83
96
  log4r (gem)
84
- if this gem is installed then MasterView will use
85
- it for logging otherwise it defaults to using built
97
+ if this gem is installed then MasterView will use
98
+ it for logging otherwise it defaults to using built
86
99
  in Logger.
87
100
 
88
101
 
@@ -104,7 +117,7 @@ The Configuration Guide describes how to customize the configuration of the Mast
104
117
 
105
118
  == Usage
106
119
 
107
- The MasterView User's Guide and a complete Directives Reference are provided in the MasterView user documentation. MasterView templates can be created by adding masterview directives markup to an (x)html ptototype, or can be generated for typical Rails controller/view scenarios using the supplied masterview generator developer tool.
120
+ The MasterView User's Guide and a complete Directives Reference are provided in the MasterView user documentation. MasterView templates can be created by adding masterview directives markup to an (x)html ptototype, or can be generated for typical Rails controller/view scenarios using the supplied masterview generator developer tool.
108
121
 
109
122
  A MasterView Admin controller can optionally be activated in your application to assist you during development with creating and managing your templates.
110
123
 
@@ -112,7 +125,7 @@ A MasterView Admin controller can optionally be activated in your application to
112
125
  == Next Steps
113
126
 
114
127
  Visit the online documentation page at http://masterview.org/ for screenshots, illustrations, complete installation and usage information.
115
-
128
+
116
129
  We would love to hear your feedback and ideas around this project! Visit the rubyforge project to join the users mailing list or to add yourself to the announce list to receive future announcements. Check out the video to see MasterView in action!
117
130
 
118
131
  Thanks for your time!!
data/doc/guide.html CHANGED
@@ -264,14 +264,17 @@ when the MasterView plugin is installed.
264
264
  In a command shell, cd to your Rails application directory and use rake commands of the form:
265
265
  </p>
266
266
 
267
- <pre class="code">
268
- rake mv:list
269
- rake mv:list_all
270
- rake mv:rebuild
271
- rake mv:rebuild_all
272
- rake mv:copy_layout
273
- rake mv:clean_mv_rhtml
274
- </pre>
267
+ <table>
268
+ <tr><th>Rake command</th><th>Description</th></tr>
269
+ <tr><td><pre class="code">rake mv:clean_mv_rhtml</pre></td><td>Cleanup/remove MasterView generated rhtml files - useful when generating erb to file system</td></tr>
270
+ <tr><td><pre class="code">rake mv:copy_layout</pre></td><td>Create shell template using layout of existing masterview template, requires TEMPLATE=foo/bar.html ACTION=list</td></tr>
271
+ <tr><td><pre class="code">rake mv:generate_all_rhtml</pre></td><td>Run parser manually on masterview html files to parse and generate the erb/rhtml files</td></tr>
272
+ <tr><td><pre class="code">rake mv:list</pre></td><td>Display list and status about each MasterView template</td></tr>
273
+ <tr><td><pre class="code">rake mv:list_all</pre></td><td>Display list, status, and full details about each MasterView template</td></tr>
274
+ <tr><td><pre class="code">rake mv:rebuild</pre></td><td>Rebuild/update html template imports, specify TEMPLATE=foo/bar.html</td></tr>
275
+ <tr><td><pre class="code">rake mv:rebuild_all</pre></td><td>Rebuild all outdated html template imports</td></tr>
276
+ <tr><td><pre class="code">rake mv:view_rhtml</pre></td><td>View erb/rhtml that masterview generated - specify rhtml name like RHTML=product/_form.rhtml or RHTML=layouts/product.rhtml</td></tr>
277
+ </table>
275
278
 
276
279
  <p>To obtain further information about the supported commands,
277
280
  run the standard rake tasks report using the <code>--tasks</code> (<code>-T</code>) option:</p>
data/doc/media_list.html CHANGED
@@ -56,22 +56,38 @@ Click for larger view</a>
56
56
 
57
57
  <h2>Presentations</h2>
58
58
  <ul>
59
+
59
60
  <li>
60
- <a href="presentations/sdruby-Nov2006/MasterView_FlyBy.pdf">MasterView FlyBy</a> - SD Ruby - Nov. 2006
61
+ <a href="http://david.koontzfamily.org/articles/Masterview.pdf">MasterView presentation</a> to Phoenix Rails User Group - May 15, 2007
61
62
  <div class="explanation">
62
- A quick overview of MasterView (history, objectives, features) by Deb Lewis at the <a href="http://sdruby.com" target="_blank">San Diego Ruby</a> User's Group.
63
- (Podcast recording available at <a href="http://podcasts.sdruby.com" target="_blank">podcasts.sdruby.com</a>.)
63
+ An explanation of MasterView starting from the problem is solves through details of how it works by David Koontz at the <a href="http://azonrails.org/" target="_blank">Phoenix Rails</a> User's Group.
64
64
  </div>
65
65
  </li>
66
- <li><a href="presentations/mtnwestruby2007/masterview_evolution_070316.html">MasterView Evolution</a> - Mountain West Ruby Conference - March 16, 2007
66
+ <li><a href="http://mtnwestrubyconf2007.confreaks.com/session05.html">MasterView Evolution from Mountain West Ruby Conference - March 16, 2007 [Video + Screencast (1 hr)]</a> | <a href="presentations/mtnwestruby2007/masterview_evolution_070316.html">[ Slides ]</a>
67
67
  <div class="explanation">
68
68
  Presentation by Jeff Barczewski at Mountain West Ruby 2007 on the MasterView template system for Rails and how its implementation has evolved from its conception in 2005 into a capable Rails plugin.
69
69
  </div>
70
70
  </li>
71
+ <li>
72
+ <a href="presentations/sdruby-Nov2006/MasterView_FlyBy.pdf">MasterView FlyBy</a> - SD Ruby - Nov. 2006
73
+ <div class="explanation">
74
+ A quick overview of MasterView (history, objectives, features) by Deb Lewis at the <a href="http://sdruby.com" target="_blank">San Diego Ruby</a> User's Group.
75
+ (Podcast recording available at <a href="http://podcasts.sdruby.com" target="_blank">podcasts.sdruby.com</a>.)
76
+ </div>
77
+ </li>
71
78
  </ul>
72
79
 
73
- <h2>Videos</h2>
80
+ <h2>Videos / Screencasts</h2>
74
81
  <ul>
82
+ <li><a href="http://masterview.org/media/html-to-live/screencast.html">Screencast from RailsConf 2007</a>
83
+ - Demonstrating using MasterView to take pure HTML prototype and quickly make it a live web Rails app. Also shows how prototype can continued to be edited throughout project life cycle and changes are instantly available in application.
84
+ <a href="http://masterview.org/media/html-to-live/screencast.html">[ Screencast 5 minutes, no audio, 25MB flash, non-streaming ]</a> |
85
+ <a href="http://masterview.org/media/html-to-live/index.html">[ Slides only]</a>
86
+ <br/><br/>
87
+ <a href="http://masterview.org/media/html-to-live/screencast.html"><img src="images/masterview_html_to_live_thumb.gif" title="MasterView HTML to Live app screencast - RailsConf 2007" alt="MasterView HTML to Live screencast - RailsConf 2007"/></a>
88
+ <br/><br/>
89
+ </li>
90
+
75
91
  <li><a href="http://masterview.org/videos/demo_short.html">MasterView Short Video</a> - demonstrating basic usage of MasterView (no audio, ~5 minutes, uses flash)<br /><br />
76
92
  <a href="http://masterview.org/videos/demo_short.html"><img src="screenshots/generated_list_thumbnail.png" title="MasterView short video" alt="MasterView short video" /></a><br /><br />
77
93
 
@@ -79,6 +95,12 @@ Presentation by Jeff Barczewski at Mountain West Ruby 2007 on the MasterView tem
79
95
  <li><a href="http://masterview.org/videos/masterview_quick_start.html">MasterView Quick Start Video</a> - longer video detailing basic configuration and operation of MasterView (no audio, ~25 minutes, uses flash)<br /><br />
80
96
  <a href="http://masterview.org/videos/masterview_quick_start.html"><img src="screenshots/masterview_admin_thumbnail.png" title="MasterView quick-start video" alt="MasterView quick-start video" /></a><br /><br />
81
97
  </li>
98
+
99
+
100
+ <li><a href="http://mtnwestrubyconf2007.confreaks.com/session05.html">MasterView Evolution from Mountain West Ruby Conference - March 16, 2007 [Video + Screencast (1 hr)]</a> | <a href="presentations/mtnwestruby2007/masterview_evolution_070316.html">[ Slides ]</a>
101
+ <br/><br/>
102
+ <a href="http://mtnwestrubyconf2007.confreaks.com/session05.html"><img src="http://mtnwestrubyconf2007.confreaks.com/images/session05_preview.png" title="MasterView Evolution video/screencast" alt="MasterView Evolution video/screencast"/></a>
103
+ </li>
82
104
  </ul>
83
105
 
84
106
  <h2>Screenshots</h2>
@@ -10,18 +10,43 @@ module MasterView
10
10
 
11
11
  module Common
12
12
 
13
+ ImportToNonImportDir = {
14
+ "import_render" => "gen_partial",
15
+ "import" => "generate",
16
+ }
17
+
18
+ NonImportToImportDir = ImportToNonImportDir.invert
19
+
13
20
  def calc_hash(data)
14
21
  #MasterView::Log.warn { 'hash= '+data.hash.to_s+' data='+data }
15
22
  data.gsub( /\s+/, ' ' ).hash #collapse whitespace
16
23
  end
17
24
 
18
25
  def src_hash(data_orig)
19
- mv_ns = DirectiveRegistry.current.mv_namespace_prefix
20
- data = data_orig.gsub mv_ns+'import_render', mv_ns+'gen_partial'
21
- data = data.gsub mv_ns+'import', mv_ns+'generate'
26
+ data = convert_import_to_non_import_dirs(data_orig)
22
27
  calc_hash(data)
23
28
  end
24
29
 
30
+ # gsub any import directives with non-import directives and return, makes clone before gsub
31
+ def convert_import_to_non_import_dirs(text)
32
+ text_clone = text.clone
33
+ mv_ns = DirectiveRegistry.current.mv_namespace_prefix
34
+ ImportToNonImportDir.sort.reverse.each do |i,n| # reverse order to substitute longer items first
35
+ text_clone.gsub! mv_ns+i, mv_ns+n # mv:import_render to mv:gen_partial and mv:import to mv:generate
36
+ end
37
+ text_clone
38
+ end
39
+
40
+ # gsub any non-import directives with import directives and return, makes clone before gsub
41
+ def convert_non_import_to_import_dirs(text)
42
+ text_clone = text.clone
43
+ mv_ns = DirectiveRegistry.current.mv_namespace_prefix
44
+ NonImportToImportDir.sort.reverse.each do |i,n| # reverse order to substitute longer items first
45
+ text_clone.gsub! mv_ns+i, mv_ns+n # mv:gen_partial to mv:import_render and mv:generate to mv:import
46
+ end
47
+ text_clone
48
+ end
49
+
25
50
  end
26
51
 
27
52
  class ContentEntry
@@ -36,14 +61,15 @@ module MasterView
36
61
  end
37
62
 
38
63
  class StackEntry
39
- attr_accessor :name, :buffer, :depth, :import, :parts
64
+ attr_accessor :name, :buffer, :depth, :import, :parts, :page_attributes
40
65
 
41
- def initialize(name, depth, import)
66
+ def initialize(name, depth, import, page_attributes)
42
67
  @name = name
43
68
  @depth = depth
44
69
  @import = import
45
70
  @buffer = []
46
71
  @parts = 0
72
+ @page_attributes = page_attributes # directives that are unique to page and ignored during synchronization
47
73
  end
48
74
 
49
75
  def inc_parts
@@ -52,12 +78,13 @@ module MasterView
52
78
  end
53
79
 
54
80
  class ListEntry
55
- attr_accessor :name, :index, :import
81
+ attr_accessor :name, :index, :import, :page_attributes
56
82
  attr_writer :hash_invalid
57
- def initialize(name, index, import)
83
+ def initialize(name, index, import, page_attributes)
58
84
  @name = name
59
85
  @index = index
60
86
  @import = import
87
+ @page_attributes = page_attributes
61
88
  end
62
89
 
63
90
  def hash_invalid?
@@ -164,6 +191,7 @@ module MasterView
164
191
  # expand the target specification to the actual path for import/generate directives in case of rebuilding
165
192
  path = nil
166
193
  import = false
194
+ page_attributes = { }
167
195
  @mv_processing_directives.each_pair { | mv_attr_name, directive_type_flags |
168
196
  if attributes.has_key?( mv_attr_name )
169
197
  expanded_attr_value = @keyword_expander.expand_keywords(attributes[mv_attr_name])
@@ -171,6 +199,8 @@ module MasterView
171
199
  if directive_type_flags[:partial]
172
200
  partial = find_string_val_in_string_hash( expanded_attr_value, :partial )
173
201
  path = render_partial_name_to_file_name(partial, @default_extname)
202
+ page_attributes[partial] = expanded_attr_value # save all the page specific values of gen_partial and import_partial by path
203
+ attributes[mv_attr_name] = ":partial => '#{partial}'" # exclude others for comparison will be put back
174
204
  else
175
205
  path = expanded_attr_value
176
206
  end
@@ -181,7 +211,7 @@ module MasterView
181
211
 
182
212
  if path
183
213
  store_last_buffer false
184
- @stack << StackEntry.new(path, @depth, import)
214
+ @stack << StackEntry.new(path, @depth, import, page_attributes)
185
215
  end
186
216
 
187
217
  unless @stack.empty?
@@ -217,11 +247,11 @@ module MasterView
217
247
 
218
248
  def end_element(uri, localname, qname)
219
249
  unless @stack.empty?
220
- if @stack.last.buffer.last == '>' && !ExpandAlwaysElements.include?(qname) #simplify empty elements
250
+ if @stack.last.buffer.last == '>' && MasterView::TemplateProcessing::Renderer::XHTMLEmptyElementNameSet.include?(qname) #collapse
221
251
  @stack.last.buffer.pop
222
252
  @stack.last.buffer << '/>'
223
253
  else
224
- @stack.last.buffer << '</' << "#{qname}>" #must output </ as separate string so simplify_empty_elements can find it
254
+ @stack.last.buffer << '</' << "#{qname}>" #must output </ as separate string so simplify_empty_elements can find it, though currently not using simplify_empty_elements in rebuilding only in parser for generation
225
255
  end
226
256
  end
227
257
 
@@ -246,33 +276,35 @@ module MasterView
246
276
 
247
277
  def store_last_buffer(end_element)
248
278
  unless @stack.empty?
249
- @stack.last.inc_parts
250
- index = end_element ? -1 : @stack.last.parts-1
251
- data = @stack.last.buffer.join
279
+ last_stack_entry = @stack.last
280
+ last_stack_entry.inc_parts
281
+ index = end_element ? -1 : last_stack_entry.parts-1
282
+ data = last_stack_entry.buffer.join
252
283
  unless @prolog.empty?
253
284
  data = @prolog.join + data
254
285
  @prolog = []
255
286
  end
287
+
256
288
  hash_invalid = false;
257
- if @stack.last.import
289
+ if last_stack_entry.import
258
290
  if only_check_hash?
259
291
  hash = src_hash(data)
260
- bdata = @builder.data(@stack.last.name, index)
292
+ bdata = @builder.data(last_stack_entry.name, index)
261
293
  hash_invalid = src_hash(bdata) != hash
262
294
  if hash_invalid
263
295
  Log.debug { 'hash_invalid contents'}
264
296
  Log.debug { 'src='+bdata }
265
297
  Log.debug { 'imp='+data }
266
298
  end
267
- #hash_invalid = @builder.hash(@stack.last.name, index) != hash
299
+ #hash_invalid = @builder.hash(last_stack_entry.name, index) != hash
268
300
  end
269
301
  elsif !only_check_hash?
270
- @content[@stack.last.name] ||= []
271
- @content[@stack.last.name] << ContentEntry.new(data)
302
+ @content[last_stack_entry.name] ||= []
303
+ @content[last_stack_entry.name] << ContentEntry.new(data)
272
304
  end
273
305
 
274
- @stack.last.buffer = []
275
- @list << ListEntry.new(@stack.last.name, index, @stack.last.import)
306
+ last_stack_entry.buffer = []
307
+ @list << ListEntry.new(last_stack_entry.name, index, last_stack_entry.import, last_stack_entry.page_attributes)
276
308
 
277
309
  if only_check_hash? #only set these flags if doing hash_check, not accurate for first round parse
278
310
  @list.last.hash_invalid = hash_invalid
@@ -694,7 +694,7 @@ module MasterView
694
694
 
695
695
  # Rails application options
696
696
  self.parse_masterview_templates_at_startup = true
697
- self.reparse_changed_masterview_templates = on_rails? ? (not ActionController::Base.perform_caching) : false
697
+ self.reparse_changed_masterview_templates = (on_rails? && defined?(::ActionController)) ? (not ::ActionController::Base.perform_caching) : false # when in cruise control ActionController was not defined yet
698
698
  self.admin_auth_mixin = nil # if defined then this module will be included in MasterView controller
699
699
  self.enable_admin_pages = is_development
700
700
  self.enable_view_rhtml = is_development
@@ -2,7 +2,7 @@ module MasterView
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -430,7 +430,7 @@ module MasterView
430
430
  last = nil
431
431
  content.flatten!
432
432
  content.each do |item|
433
- if next_to_last == '>' && last == '</' && XHTMLEmptyElementNameSet.include?(current_element_name)
433
+ if next_to_last == '>' && last == '</' && XHTMLEmptyElementNameSet.include?(current_element_name) # collapse
434
434
  ret.pop #remove '>'
435
435
  ret.pop #remove '</'
436
436
  ret << ' />' # adding in a space to make xhtml more compatible with html editors and older browsers
@@ -617,6 +617,8 @@ module MasterView
617
617
  generate_attribute = attributes[@renderer.mv_generate_attr] || '' # check if we need to add to existing generate
618
618
  generate_attribute = path + (generate_attribute.blank? ? '' : ', '+generate_attribute)
619
619
  attributes[@renderer.mv_generate_attr] = generate_attribute
620
+ page_locals = @renderer.keyword_expander.resolveAttrAndDelete(attributes, "mvpg:locals") #todo make this dynamic
621
+ value = (value.trim.empty?) ? page_locals : "#{value}, :locals => {#{page_locals}}" if page_locals #todo need to handle trailing }
620
622
  @renderer.append_raw( ERB_CONTENT_START+'render( '+value+' )'+ERB_CONTENT_END )
621
623
  end
622
624
  end
@@ -4,8 +4,20 @@ module MasterView
4
4
  # template. It contains the information on all the parts that make up the template
5
5
  # and the status of them (whether they are up to date or out of sync).
6
6
  class TemplateSpec
7
+ include Analyzer::Common
8
+ include DirectiveHelpers
7
9
  attr_accessor :path, :status, :message, :gen_parts, :build_list
8
10
 
11
+ # setup a class instance gen_partial_re that is created on use so that namespace is already setup
12
+ class << self
13
+ attr_accessor :gen_partial_regex_cached
14
+
15
+ def gen_partial_re
16
+ self.gen_partial_regex_cached ||= Regexp.new(
17
+ "#{DirectiveRegistry.current.mv_namespace_prefix}gen_partial\\s*=\\s*((\")([^\"]*)\"|(')([^']*'))" )
18
+ end
19
+ end
20
+
9
21
  class Status
10
22
  OK = 'OK'
11
23
  ImportsOutdated = 'Imports(s) outdated'
@@ -116,10 +128,37 @@ module MasterView
116
128
  @build_list.each do |li|
117
129
  #Log.debug { li.inspect }
118
130
  con = builder.data(li.name, li.index)
131
+
132
+ unless li.page_attributes.empty? # if we have page_attributes, reinsert them now, currently only inserting for partials
133
+ gpmatch = TemplateSpec.gen_partial_re.match(con)
134
+
135
+ if gpmatch
136
+ gen_partial_all = gpmatch[0]
137
+ gp_quote_char = gpmatch[2] || gpmatch[4]
138
+ gen_partial_fullattr = gpmatch[3] || gpmatch[5]
139
+
140
+ # determine what partial page we are rendering to see if we have any page specific attributes
141
+ partial = find_string_val_in_string_hash(gen_partial_fullattr, :partial)
142
+ if partial
143
+ partial_pa = li.page_attributes[partial] # retrieve page specific attribute by file name
144
+ if partial_pa # if we have one, replace it in the text
145
+ mv_ns = DirectiveRegistry.current.mv_namespace_prefix
146
+ con.gsub! TemplateSpec.gen_partial_re, "#{mv_ns}gen_partial=#{gp_quote_char}#{partial_pa}#{gp_quote_char}"
147
+ end
148
+ end
149
+ end
150
+
151
+ # sorted_page_att_arr = li.page_attributes.sort{ |a,b| a[0].to_s <=> b[0].to_s } #[[a, 2], [b, 1]]
152
+ # sorted_page_att = sorted_page_att_arr.collect{ |a| "#{a[0]}=\"#{a[1]}\"" } # a="2"
153
+ # pg_att_ins = sorted_page_att.join(' ')
154
+ # mv_ns = DirectiveRegistry.current.mv_namespace_prefix
155
+ # con.gsub! "#{mv_ns}gen_partial", "#{pg_att_ins} #{mv_ns}gen_partial"
156
+
157
+ #Log.debug { con.inspect }
158
+ end
159
+
119
160
  if li.import
120
- mv_ns = DirectiveRegistry.current.mv_namespace_prefix
121
- con = con.gsub mv_ns+'generate', mv_ns+'import'
122
- con.gsub! mv_ns+'gen_partial', mv_ns+'import_render'
161
+ con = convert_non_import_to_import_dirs(con) #gsub mv:gen_partial to mv:import_render and mv:generate to mv:import
123
162
  end
124
163
  out << con
125
164
  end
@@ -176,7 +215,7 @@ module MasterView
176
215
  li = from_spec.build_list.first
177
216
  li.import = true
178
217
  to_spec.build_list << li
179
- to_spec.build_list << MasterView::Analyzer::ListEntry.new('empty_shell_contents', -1, false)
218
+ to_spec.build_list << MasterView::Analyzer::ListEntry.new('empty_shell_contents', -1, false, {} )
180
219
  li = from_spec.build_list.last
181
220
  li.import = true
182
221
  to_spec.build_list << li
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ currentPath = File.dirname(__FILE__)
5
+
6
+ require File.join( currentPath, '../../lib/masterview/initializer' )
7
+ config = MasterView::Configuration.new( :app_root_path => '/path/to/my/app' )
8
+ # config.template_src_dir_path = "masterview/templates"
9
+ # config.template_dst_dir_path = "masterview/output"
10
+ # #...set other config options...
11
+ # MasterView::Initializer.run( :process, config )
12
+
13
+
14
+ require File.join( currentPath, '../../lib/masterview' )
15
+
16
+
17
+ # require 'masterview/initializer'
18
+ # config = MasterView::Configuration.new( :app_root_path => '/path/to/my/app' )
19
+ # config.template_src_dir_path = "masterview/templates"
20
+ # config.template_dst_dir_path = "masterview/output"
21
+ # #...set other config options...
22
+ # MasterView::Initializer.run( :process, config )
23
+
24
+
25
+ class TestParser < Test::Unit::TestCase
26
+ CurrentPath = File.dirname(__FILE__)
27
+ TestFixturesDir = File.join(CurrentPath, '../fixtures/templates')
28
+ MasterViewHTMLFile = 'product.html'
29
+ TmpOutputDir = File.join(CurrentPath, '../tmp/views')
30
+
31
+ def setup
32
+ FileUtils.remove_dir(TmpOutputDir, true)
33
+ @template_mio_tree = MasterView::MIO::FileMIOTree.new(TestFixturesDir, '.html')
34
+ @template_mio = @template_mio_tree.path(MasterViewHTMLFile)
35
+ @erb_mio_tree = MasterView::MIO::FileMIOTree.new(TmpOutputDir, '.rhtml')
36
+ @orig_generate_rhtml_files_setting = MasterView::ConfigSettings.generate_rhtml_files
37
+ end
38
+
39
+ def teardown
40
+ MasterView::ConfigSettings.generate_rhtml_files = @orig_generate_rhtml_files_setting
41
+ @template_mio_tree = nil
42
+ @template_mio = nil
43
+ @erb_mio_tree = nil
44
+ @orig_generate_rhtml_files_setting = nil
45
+ end
46
+
47
+ def test_parser_run
48
+ MasterView::Parser.parse_mio( @template_mio, @erb_mio_tree)
49
+ assert File.exist?(TmpOutputDir+'/layouts/product.rhtml')
50
+ assert File.exist?(TmpOutputDir+'/product/_form.rhtml')
51
+ assert File.exist?(TmpOutputDir+'/product/edit.rhtml')
52
+ assert File.exist?(TmpOutputDir+'/product/list.rhtml')
53
+ assert File.exist?(TmpOutputDir+'/product/new.rhtml')
54
+ assert File.exist?(TmpOutputDir+'/product/show.rhtml')
55
+ end
56
+
57
+
58
+ def test_gen_rhtml
59
+ # mimic what masterview.rake#mv:parse does
60
+ MasterView::ConfigSettings.generate_rhtml_files = true
61
+ @template_mio_tree.find(:pattern => MasterView::TemplateFilenamePattern ) do |mio|
62
+ puts 'Generated erb/rhtml files from '+mio.pathname.to_s
63
+ MasterView::Parser.parse_mio(mio, MasterView::IOMgr.erb)
64
+ end
65
+ if MasterView::ConfigSettings.generate_rhtml_files
66
+ puts 'Generated erb/rhtml output was created in app/views/** tree'
67
+ else
68
+ puts "\nNote: config.generate_rhtml_files was false, so rails reads erb/rhtml directly from MasterView, and thus files were parsed but not serialized to file system. Set config.generate_rhtml_files = true (in config/masterview/settings.rb) and rerun this command to generate rhtml to the file system"
69
+ end
70
+
71
+
72
+ assert File.exist?(TmpOutputDir+'/layouts/product.rhtml')
73
+ assert File.exist?(TmpOutputDir+'/product/_form.rhtml')
74
+ assert File.exist?(TmpOutputDir+'/product/edit.rhtml')
75
+ assert File.exist?(TmpOutputDir+'/product/list.rhtml')
76
+ assert File.exist?(TmpOutputDir+'/product/new.rhtml')
77
+ assert File.exist?(TmpOutputDir+'/product/show.rhtml')
78
+ end
79
+
80
+ end
81
+
82
+
@@ -125,6 +125,48 @@ class TestTemplateSpec < Test::Unit::TestCase
125
125
  assert_equal %w{ bar/baz.rhtml cat/_foo.rhtml layout/foo.rhtml }, spec2.gen_parts
126
126
  end
127
127
 
128
+ def test_imports_not_outdated_ignore_page_directives
129
+ content_hash = {}
130
+ template1 = <<-END
131
+ <html mv:import="layout/foo.rhtml">
132
+ <body>
133
+ <div mv:import="bar/baz.rhtml">
134
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'foo bar'}">
135
+ Hello
136
+ </div>
137
+ </div>
138
+ </body>
139
+ </html>
140
+ END
141
+ spec1 = MasterView::TemplateSpec.scan_template(template1, 'hello', content_hash)
142
+ template2 = <<-END
143
+ <html mv:generate="layout/foo.rhtml">
144
+ <body>
145
+ <div mv:generate="bar/baz.rhtml">
146
+ <div mv:gen_partial=":partial => 'cat/foo', :locals=> {:title => 'cat dog'}">
147
+ Hello
148
+ </div>
149
+ </div>
150
+ </body>
151
+ </html>
152
+ END
153
+ spec2 = MasterView::TemplateSpec.scan_template(template2, 'world', content_hash)
154
+
155
+ invalid_parts = MasterView::TemplateSpec.template_out_of_sync?(template1, 'hello', content_hash)
156
+ spec1.update_status_from_invalid_parts(invalid_parts)
157
+ assert_equal [], invalid_parts
158
+ assert_equal MasterView::TemplateSpec::Status::OK, spec1.status
159
+ assert_equal '', spec1.message
160
+ assert_equal [], spec1.gen_parts
161
+
162
+ invalid_parts = MasterView::TemplateSpec.template_out_of_sync?(template2, 'world', content_hash)
163
+ spec2.update_status_from_invalid_parts(invalid_parts)
164
+ assert_equal [], invalid_parts
165
+ assert_equal MasterView::TemplateSpec::Status::OK, spec2.status
166
+ assert_equal '', spec2.message
167
+ assert_equal %w{ bar/baz.rhtml cat/_foo.rhtml layout/foo.rhtml }, spec2.gen_parts
168
+ end
169
+
128
170
  def test_imports_outdated
129
171
  content_hash = {}
130
172
  template1 = <<-END
@@ -167,7 +209,7 @@ class TestTemplateSpec < Test::Unit::TestCase
167
209
  assert_equal '', spec2.message
168
210
  assert_equal %w{ bar/baz.rhtml cat/_foo.rhtml layout/foo.rhtml }, spec2.gen_parts
169
211
  end
170
-
212
+
171
213
  def test_rebuild_template
172
214
  content_hash = {}
173
215
  template1 = <<-END
@@ -219,6 +261,291 @@ END
219
261
  assert_equal expected_rebuilt_template.strip, rebuilt_template
220
262
  end
221
263
 
264
+ def test_rebuild_template_simplify_elements
265
+ content_hash = {}
266
+ template1 = <<-END
267
+ <html mv:import="layout/foo.rhtml">
268
+ <body>
269
+ This should make it outdated
270
+ <div mv:import="bar/baz.rhtml">
271
+ <div mv:import_render=":partial => 'cat/foo'">
272
+ Hello this will also make this outdated
273
+ </div>
274
+ </div>
275
+ </body>
276
+ </html>
277
+ END
278
+ spec1 = MasterView::TemplateSpec.scan_template(template1, 'hello', content_hash)
279
+ template2 = <<-END
280
+ <html mv:generate="layout/foo.rhtml">
281
+ <body>
282
+ <label></label>
283
+ <textarea></textarea>
284
+ <script></script>
285
+ <br></br>
286
+ <hr></hr>
287
+ <div mv:generate="bar/baz.rhtml">
288
+ <div mv:gen_partial=":partial => 'cat/foo'">
289
+ Hello
290
+ </div>
291
+ </div>
292
+ </body>
293
+ </html>
294
+ END
295
+ spec2 = MasterView::TemplateSpec.scan_template(template2, 'world', content_hash)
296
+
297
+ invalid_parts = MasterView::TemplateSpec.template_out_of_sync?(template1, 'hello', content_hash)
298
+ spec1.update_status_from_invalid_parts(invalid_parts)
299
+ assert_equal %w{ cat/_foo.rhtml layout/foo.rhtml }, invalid_parts
300
+ assert_equal MasterView::TemplateSpec::Status::ImportsOutdated, spec1.status
301
+ assert_equal 'Outdated parts: cat/_foo.rhtml, layout/foo.rhtml', spec1.message
302
+ assert_equal [], spec1.gen_parts
303
+
304
+ expected_rebuilt_template = <<-END
305
+ <html mv:import="layout/foo.rhtml">
306
+ <body>
307
+ <label></label>
308
+ <textarea></textarea>
309
+ <script></script>
310
+ <br/>
311
+ <hr/>
312
+ <div mv:import="bar/baz.rhtml">
313
+ <div mv:import_render=":partial => 'cat/foo'">
314
+ Hello
315
+ </div>
316
+ </div>
317
+ </body>
318
+ </html>
319
+ END
320
+
321
+ rebuilt_template = spec1.rebuild_template(content_hash)
322
+ assert_equal expected_rebuilt_template.strip, rebuilt_template
323
+ end
324
+
325
+ def test_rebuild_template_with_page_attributes
326
+ content_hash = {}
327
+ template1 = <<-END
328
+ <html mv:import="layout/foo.rhtml">
329
+ <body>
330
+ This should make it outdated
331
+ <div mv:import="bar/baz.rhtml">
332
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dogs like cats'}">
333
+ Hello this will also make this outdated
334
+ </div>
335
+ </div>
336
+ </body>
337
+ </html>
338
+ END
339
+ spec1 = MasterView::TemplateSpec.scan_template(template1, 'hello', content_hash)
340
+ template2 = <<-END
341
+ <html mv:generate="layout/foo.rhtml">
342
+ <body>
343
+ <div mv:generate="bar/baz.rhtml">
344
+ <div mv:gen_partial=":partial => 'cat/foo', :locals => {:title => 'blue sky'}" zebra=":zen => 'phone'">
345
+ Hello
346
+ </div>
347
+ </div>
348
+ </body>
349
+ </html>
350
+ END
351
+ spec2 = MasterView::TemplateSpec.scan_template(template2, 'world', content_hash)
352
+
353
+ invalid_parts = MasterView::TemplateSpec.template_out_of_sync?(template1, 'hello', content_hash)
354
+ spec1.update_status_from_invalid_parts(invalid_parts)
355
+ assert_equal %w{ cat/_foo.rhtml layout/foo.rhtml }, invalid_parts
356
+ assert_equal MasterView::TemplateSpec::Status::ImportsOutdated, spec1.status
357
+ assert_equal 'Outdated parts: cat/_foo.rhtml, layout/foo.rhtml', spec1.message
358
+ assert_equal [], spec1.gen_parts
359
+
360
+ expected_rebuilt_template = <<-END
361
+ <html mv:import="layout/foo.rhtml">
362
+ <body>
363
+ <div mv:import="bar/baz.rhtml">
364
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dogs like cats'}" zebra=":zen => 'phone'">
365
+ Hello
366
+ </div>
367
+ </div>
368
+ </body>
369
+ </html>
370
+ END
371
+
372
+ rebuilt_template = spec1.rebuild_template(content_hash)
373
+ assert_equal expected_rebuilt_template.strip, rebuilt_template
374
+ end
375
+
376
+ def test_rebuild_template_with_page_attributes_nested_partials
377
+ content_hash = {}
378
+ template1 = <<-END
379
+ <html mv:import="layout/foo.rhtml">
380
+ <body>
381
+ This should make it outdated
382
+ <div mv:import="bar/baz.rhtml">
383
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dogs like cats'}">
384
+ Hello this will also make this outdated
385
+ <div mv:import_render=":partial => 'green/red', :locals => {:rows => 5}">
386
+ My inner partial which should get fully replaced
387
+ </div>
388
+ </div>
389
+ </div>
390
+ </body>
391
+ </html>
392
+ END
393
+ spec1 = MasterView::TemplateSpec.scan_template(template1, 'hello', content_hash)
394
+ template2 = <<-END
395
+ <html mv:generate="layout/foo.rhtml">
396
+ <body>
397
+ <div mv:generate="bar/baz.rhtml">
398
+ <div mv:gen_partial=":partial => 'cat/foo', :locals => {:title => 'blue sky'}">
399
+ Hello
400
+ <div mv:gen_partial=":partial => 'green/red', :locals => {:rows => 10}">
401
+ My inner partial
402
+ </div>
403
+ </div>
404
+ </div>
405
+ </body>
406
+ </html>
407
+ END
408
+ spec2 = MasterView::TemplateSpec.scan_template(template2, 'world', content_hash)
409
+
410
+ invalid_parts = MasterView::TemplateSpec.template_out_of_sync?(template1, 'hello', content_hash)
411
+ spec1.update_status_from_invalid_parts(invalid_parts)
412
+ assert_equal %w{ cat/_foo.rhtml green/_red.rhtml layout/foo.rhtml }, invalid_parts
413
+ assert_equal MasterView::TemplateSpec::Status::ImportsOutdated, spec1.status
414
+ assert_equal 'Outdated parts: cat/_foo.rhtml, green/_red.rhtml, layout/foo.rhtml', spec1.message
415
+ assert_equal [], spec1.gen_parts
416
+
417
+ expected_rebuilt_template = <<-END
418
+ <html mv:import="layout/foo.rhtml">
419
+ <body>
420
+ <div mv:import="bar/baz.rhtml">
421
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dogs like cats'}">
422
+ Hello
423
+ <div mv:import_render=":partial => 'green/red', :locals => {:rows => 5}">
424
+ My inner partial
425
+ </div>
426
+ </div>
427
+ </div>
428
+ </body>
429
+ </html>
430
+ END
431
+
432
+ rebuilt_template = spec1.rebuild_template(content_hash)
433
+ assert_equal expected_rebuilt_template.strip, rebuilt_template
434
+ end
435
+
436
+ def test_rebuild_template_page_attributes_multiple_partials_same_name
437
+ content_hash = {}
438
+ template1 = <<-END
439
+ <html mv:import="layout/foo.rhtml">
440
+ <body>
441
+ This should make it outdated
442
+ <div mv:import="bar/baz.rhtml">
443
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dogs like cats'}">
444
+ Hello this will also make this outdated
445
+ </div>
446
+ text here
447
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'frogs like water'}">
448
+ Hello this will also make this outdated
449
+ </div>
450
+ </div>
451
+ </body>
452
+ </html>
453
+ END
454
+ spec1 = MasterView::TemplateSpec.scan_template(template1, 'hello', content_hash)
455
+ template2 = <<-END
456
+ <html mv:generate="layout/foo.rhtml">
457
+ <body>
458
+ <div mv:generate="bar/baz.rhtml">
459
+ <div mv:gen_partial=":partial => 'cat/foo', :locals => {:title => 'blue sky'}">
460
+ Hello
461
+ </div>
462
+ text here
463
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dark sky'}">
464
+ Hello replaced
465
+ </div>
466
+ </div>
467
+ </body>
468
+ </html>
469
+ END
470
+ spec2 = MasterView::TemplateSpec.scan_template(template2, 'world', content_hash)
471
+
472
+ invalid_parts = MasterView::TemplateSpec.template_out_of_sync?(template1, 'hello', content_hash)
473
+ spec1.update_status_from_invalid_parts(invalid_parts)
474
+ assert_equal %w{ cat/_foo.rhtml layout/foo.rhtml }, invalid_parts
475
+ assert_equal MasterView::TemplateSpec::Status::ImportsOutdated, spec1.status
476
+ assert_equal 'Outdated parts: cat/_foo.rhtml, layout/foo.rhtml', spec1.message
477
+ assert_equal [], spec1.gen_parts
478
+
479
+ expected_rebuilt_template = <<-END
480
+ <html mv:import="layout/foo.rhtml">
481
+ <body>
482
+ <div mv:import="bar/baz.rhtml">
483
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dogs like cats'}">
484
+ Hello
485
+ </div>
486
+ text here
487
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'frogs like water'}">
488
+ Hello
489
+ </div>
490
+ </div>
491
+ </body>
492
+ </html>
493
+ END
494
+
495
+ rebuilt_template = spec1.rebuild_template(content_hash)
496
+ assert_equal expected_rebuilt_template.strip, rebuilt_template
497
+ end
498
+
499
+ def test_rebuild_template_page_attributes_multiple_partials_mixed_gen_and_import
500
+ content_hash = {}
501
+ template1 = <<-END
502
+ <html mv:generate="layout/foo.rhtml">
503
+ <body>
504
+ <div mv:generate="bar/baz.rhtml">
505
+ <div mv:gen_partial=":partial => 'cat/foo', :locals => {:title => 'blue sky'}">
506
+ Hello
507
+ </div>
508
+ text here
509
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dark sky'}">
510
+ Hello replaced
511
+ </div>
512
+ </div>
513
+ </body>
514
+ </html>
515
+ END
516
+ spec1 = MasterView::TemplateSpec.scan_template(template1, 'hello', content_hash)
517
+
518
+ invalid_parts = MasterView::TemplateSpec.template_out_of_sync?(template1, 'hello', content_hash)
519
+ spec1.update_status_from_invalid_parts(invalid_parts)
520
+ assert_equal %w{ cat/_foo.rhtml }, invalid_parts
521
+ assert_equal MasterView::TemplateSpec::Status::ImportsOutdated, spec1.status
522
+ assert_equal 'Outdated parts: cat/_foo.rhtml', spec1.message
523
+ assert_equal %w{ bar/baz.rhtml cat/_foo.rhtml layout/foo.rhtml }, spec1.gen_parts
524
+
525
+ expected_rebuilt_template = <<-END
526
+ <html mv:generate="layout/foo.rhtml">
527
+ <body>
528
+ <div mv:generate="bar/baz.rhtml">
529
+ <div mv:gen_partial=":partial => 'cat/foo', :locals => {:title => 'blue sky'}">
530
+ Hello
531
+ </div>
532
+ text here
533
+ <div mv:import_render=":partial => 'cat/foo', :locals => {:title => 'dark sky'}">
534
+ Hello
535
+ </div>
536
+ </div>
537
+ </body>
538
+ </html>
539
+ END
540
+
541
+ rebuilt_template = spec1.rebuild_template(content_hash)
542
+ assert_equal expected_rebuilt_template.strip, rebuilt_template
543
+ end
544
+
545
+
546
+
547
+
548
+
222
549
  # test the creation of an empty shell using simply the source and action inferring the rest
223
550
  def test_create_empty_shell_for_action
224
551
  source = <<-END
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: masterview
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.3
7
- date: 2007-07-01 00:00:00 -05:00
6
+ version: 0.3.4
7
+ date: 2007-10-04 00:00:00 -05:00
8
8
  summary: A (x)html friendly template engine for rails with the power of layouts, and partials.
9
9
  require_paths:
10
10
  - lib
@@ -246,6 +246,7 @@ files:
246
246
  - test/unit/deprecated_directive_base_test.rb
247
247
  - test/unit/example_directive_base_old_test.rb
248
248
  - test/unit/deprecated_directive_base_example_test.rb
249
+ - test/unit/#run_parser_test.rb#
249
250
  - test/unit/short_path_calc_test.rb
250
251
  - test/xtras/config_initialize_standalone.rb
251
252
  - test/xtras/config-mv-logger_config.rb