masterview 0.1.5 → 0.2.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.
Files changed (105) hide show
  1. data/CHANGELOG +17 -0
  2. data/README +36 -504
  3. data/RELEASE_NOTES +126 -45
  4. data/Rakefile +215 -86
  5. data/TODO +8 -3
  6. data/doc/configuration.html +485 -0
  7. data/doc/directives.html +1085 -0
  8. data/doc/guide.html +243 -0
  9. data/doc/index.html +287 -0
  10. data/doc/installation.html +376 -0
  11. data/doc/stylesheets/masterview.css +206 -0
  12. data/doc/stylesheets/mv-config.css +23 -0
  13. data/doc/stylesheets/mv-directives.css +18 -0
  14. data/doc/stylesheets/mv-installation.css +10 -0
  15. data/doc/troubleshooting.html +18 -0
  16. data/examples/product.html +256 -0
  17. data/examples/product.html.old +107 -0
  18. data/examples/rails_app_config/masterview/environment/development.rb +22 -0
  19. data/examples/rails_app_config/masterview/environment/production.rb +9 -0
  20. data/examples/rails_app_config/masterview/settings.rb +59 -0
  21. data/examples/test.import +80 -0
  22. data/init.rb +26 -12
  23. data/lib/masterview/analyzer.rb +25 -15
  24. data/lib/masterview/directive_base.rb +4 -0
  25. data/lib/masterview/directive_helpers.rb +7 -5
  26. data/lib/masterview/directives/import_render.rb +6 -0
  27. data/lib/masterview/directives/insert_generated_comment.rb +8 -8
  28. data/lib/masterview/extras/app/controllers/masterview_controller.rb +154 -2
  29. data/lib/masterview/extras/app/views/masterview/admin/create.rhtml +4 -4
  30. data/lib/masterview/extras/app/views/masterview/admin/empty.rhtml +1 -1
  31. data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +14 -9
  32. data/lib/masterview/extras/app/views/masterview/admin/view_rhtml.rhtml +70 -0
  33. data/lib/masterview/extras/init_logger.rb +102 -0
  34. data/lib/masterview/extras/init_rails_erb_mv_direct.rb +117 -0
  35. data/lib/masterview/extras/init_rails_reparse_checking.rb +59 -0
  36. data/lib/masterview/extras/watcher.rb +17 -23
  37. data/lib/masterview/filter_helpers.rb +26 -0
  38. data/lib/masterview/initializer.rb +912 -0
  39. data/lib/masterview/io.rb +352 -0
  40. data/lib/masterview/keyword_expander.rb +116 -0
  41. data/lib/masterview/masterview_version.rb +2 -2
  42. data/lib/masterview/mtime_tracking_hash.rb +44 -0
  43. data/lib/masterview/parser.rb +64 -92
  44. data/lib/masterview/pathname_extensions.rb +33 -0
  45. data/lib/masterview/template_spec.rb +49 -56
  46. data/lib/masterview.rb +40 -85
  47. data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/development.rb +12 -0
  48. data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/production.rb +11 -0
  49. data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/settings.rb +23 -0
  50. data/test/fixtures/templates/product.html +256 -0
  51. data/test/fixtures/templates/test.import +80 -0
  52. data/test/test_helper.rb +5 -3
  53. data/test/tmp/template/foo.txt +1 -0
  54. data/test/tmp/templates_src/product.html +256 -0
  55. data/test/tmp/views/layouts/product.rhtml +35 -0
  56. data/test/tmp/views/product/_form.rhtml +30 -0
  57. data/test/tmp/views/product/_product.rhtml +14 -0
  58. data/test/tmp/views/product/_show.rhtml +27 -0
  59. data/test/tmp/views/product/destroy.rhtml +27 -0
  60. data/test/tmp/views/product/edit.rhtml +26 -0
  61. data/test/tmp/views/product/list.rhtml +31 -0
  62. data/test/tmp/views/product/new.rhtml +29 -0
  63. data/test/tmp/views/product/show.rhtml +16 -0
  64. data/test/unit/config_settings_test.rb +172 -0
  65. data/test/{attr_test.rb → unit/directive_attr_test.rb} +2 -2
  66. data/test/{block_test.rb → unit/directive_block_test.rb} +2 -2
  67. data/test/{content_test.rb → unit/directive_content_test.rb} +2 -2
  68. data/test/{else_test.rb → unit/directive_else_test.rb} +2 -2
  69. data/test/{elsif_test.rb → unit/directive_elsif_test.rb} +2 -2
  70. data/test/{form_test.rb → unit/directive_form_test.rb} +2 -2
  71. data/test/{global_inline_erb_test.rb → unit/directive_global_inline_erb_test.rb} +2 -2
  72. data/test/{hidden_field_test.rb → unit/directive_hidden_field_test.rb} +2 -2
  73. data/test/{if_test.rb → unit/directive_if_test.rb} +2 -2
  74. data/test/unit/directive_import_render_test.rb +62 -0
  75. data/test/{import_test.rb → unit/directive_import_test.rb} +2 -2
  76. data/test/{javascript_include_test.rb → unit/directive_javascript_include_test.rb} +2 -2
  77. data/test/{link_to_if_test.rb → unit/directive_link_to_if_test.rb} +2 -2
  78. data/test/{link_to_test.rb → unit/directive_link_to_test.rb} +2 -2
  79. data/test/{omit_tag_test.rb → unit/directive_omit_tag_test.rb} +2 -2
  80. data/test/{password_field_test.rb → unit/directive_password_field_test.rb} +2 -2
  81. data/test/{replace_test.rb → unit/directive_replace_test.rb} +2 -2
  82. data/test/{stylesheet_link_test.rb → unit/directive_stylesheet_link_test.rb} +2 -2
  83. data/test/{submit_test.rb → unit/directive_submit_test.rb} +2 -2
  84. data/test/{text_area_test.rb → unit/directive_text_area_test.rb} +2 -2
  85. data/test/{text_field_test.rb → unit/directive_text_field_test.rb} +2 -2
  86. data/test/{example_test.rb → unit/example_test.rb} +1 -1
  87. data/test/unit/file_mio_test.rb +368 -0
  88. data/test/{filter_helpers_test.rb → unit/filter_helpers_test.rb} +1 -1
  89. data/test/unit/keyword_expander_test.rb +95 -0
  90. data/test/unit/mio_test.rb +110 -0
  91. data/test/unit/mtime_string_hash_mio_tree_test.rb +289 -0
  92. data/test/unit/mtime_tracking_hash_test.rb +38 -0
  93. data/test/{parser_test.rb → unit/parser_test.rb} +19 -1
  94. data/test/unit/pathname_extensions_test.rb +46 -0
  95. data/test/{run_parser_test.rb → unit/run_parser_test.rb} +7 -3
  96. data/test/unit/string_hash_mio_test.rb +320 -0
  97. data/test/unit/template_file_watcher_test.rb +107 -0
  98. data/test/{template_spec_test.rb → unit/template_spec_test.rb} +57 -21
  99. data/test/{template_test.rb → unit/template_test.rb} +123 -22
  100. data/test/xtras/config-mv-logger_config.rb +109 -0
  101. data/test/xtras/config_initialize_standalone.rb +53 -0
  102. metadata +111 -38
  103. data/lib/masterview/extras/rails_init.rb +0 -72
  104. data/test/import_render_test.rb +0 -30
  105. data/test/template_file_watcher_test.rb +0 -50
data/CHANGELOG CHANGED
@@ -1,3 +1,20 @@
1
+ 0.2.0 - June 20th, 2006 - Big release. Added capability for eliminating rhtml generation, extends rails so that rhtml can be pulled directly from MasterView.
2
+ Support template compilation directly into Rails view cache for templates in app/views (rhtml generation now optional)
3
+ New mechanism for configuring MasterView from settings files; internal initialization rework. Configuration can now be driven by editing config/masterview/settings.rb and/or config/masterview/environments/*.rb.
4
+ Add support for configuring MasterView logger and log_level; default level INFO for dev, WARN otherwise
5
+ Add keyword substitution for generate/import attributes (mv:generate="{template_path}" notation)
6
+ Added capability to view rhtml from MasterView Admin pages.
7
+ Add 'View Configuration' page in MasterView Admin pages to display config settings.
8
+ Reorganize and enhance documentation: doc/index.html; improved installation guide, added config guide, improved User Guide
9
+ Internals: Renamed PartialExtension to GeneratedFileDefaultExtension
10
+ Internals: Renamed partial_filename_extension to generated_file_default_extension
11
+ Internals: Major internal rework of file handling and I/O.
12
+ --UPGRADE NOTE: you *must* redo any config customizations in plugin init.rb to use new settings file and config vars
13
+ --UPGRADE NOTE: default location for masterview template files is now the app/views directory in your Rails app
14
+ --UPGRADE NOTE: directive gen_render was renamed gen_partial for clarity, update any templates which reference gen_render
15
+
16
+ 0.1.6 - June 2nd - Implement basic dateselect and datetime_select in generator. Simplify only empty elements that are specified as empty in xhtml-1.0-Strict DTD.
17
+
1
18
  0.1.5 - May 31st - Remove app_[ENV] customization hook in leau of a block based initializer approach (similar to rails) from Deborah Lewis which would allow customization from the environment config files.
2
19
 
3
20
  0.1.4 - May 30th - Apply patch by Deborah Lewis to allow customized generated comment. Add omit_tag directive to conditionally suppress output of element tag. Add user configuration user.rb, user_RAILS_ENV.rb
data/README CHANGED
@@ -5,14 +5,20 @@ It is designed to use the full power and productivity of rails including
5
5
  layouts, partials, and rails html helpers while still being editable/styleable
6
6
  in a WYSIWYG HTML editor.
7
7
 
8
- MasterView is distributed as a gem or a plugin. You may install it as a gem and then generate a lightweight plugin which mainly refers to the gem *or* you can simply install as a plugin which is self contained. I personally prefer installing as a gem for ease of management, however if you are running at a shared hosting environment you might not have authority to install this gem so you may install as a self contained plugin.
8
+ MasterView is distributed as a gem or a plugin. You may install it as a gem and
9
+ then generate a lightweight plugin which mainly refers to the gem *or* you can
10
+ simply install as a plugin which is self contained. I personally prefer installing
11
+ as a gem for ease of management, however if you are running at a shared hosting
12
+ environment you might not have authority to install this gem so you may install
13
+ as a self contained plugin.
9
14
 
10
15
  If you are interested in the background story behind all this, it is at the end of this page.
11
16
 
12
17
  Author:: Jeff Barczewski
13
18
  Email:: jeff.barczewski @ gmail.com
14
- Rubyforge project:: masterview
19
+ Primary developers:: Jeff Barczewski, Deb Lewis
15
20
  Website:: http://masterview.org
21
+ Rubyforge project:: masterview
16
22
  License:: MIT open source license like Rails
17
23
 
18
24
  == Goals
@@ -35,513 +41,32 @@ Optional::
35
41
  tidy (gem) and tidy library - if these are installed you can use tidy to cleanup html into valid xhtml for use by MasterView
36
42
  log4r (gem) - if this gem is installed then MasterView will use it for logging otherwise it defaults to using built in Logger.
37
43
 
38
- == Installation
39
-
40
- Install in one of the two following ways depending on whether you can use gems or not.
41
-
42
- === Installation using gems (if you are able to use gems)
44
+ == User Documentation
43
45
 
44
- If you can use gems you may simply do the following
46
+ MasterView documentation is available online at the MasterView site:
47
+ http://www.masterview.org
48
+ and on the rubyforge project
49
+ http://rubyforge.org/projects/masterview/
45
50
 
46
- gem install masterview_gem_pack
47
-
48
- Now your gem is installed and you can skip these steps in the future. After creating your rails directory, change directory to it and run the following to create a very lightweight plugin instance for this application mainly consisting of an init.rb file which will get loaded at runtime. This init.rb refers to the gem for everything but allows you to override any constants or setup that has been provided. See MasterView module masterview.rb for a list of the available constants.
49
-
50
- script/generate masterview_plugin
51
-
52
- After this MasterView is ready for use. Skip down to the Usage section for more details.
53
-
54
- === Installation without using gems, install as plugin
51
+ == Installation
55
52
 
56
- script/plugin install svn://rubyforge.org/var/svn/masterview/tags/latest
53
+ Detailed installation instructions for installing the masterview gems
54
+ or a self-contained copy of the plugin is provided in the MasterView
55
+ Installation Guide.
57
56
 
58
- This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. Note that if you don't have svn (subversion) installed, you may also retrieve the plugin package (masterview_plugin.tgz or masterview_plugin.zip) from http://rubyforge.org/projects/masterview and simply extract into vendor/plugins/masterview
57
+ The Configuration Guide describes how to customize the configuration
58
+ of the MasterView template engine for your application.
59
59
 
60
60
  == Usage
61
61
 
62
- You may add MasterView attributes to existing (x)html or you may use the masterview generator to create a complete working application. The generator can create controllers, models, and the MasterView template file similar to how the built-in generator works. Simply change directory to your rails application and run the following
63
-
64
- script/generate masterview YourModelName [YourControllerName] [--style [cssStylesheet]] [--single-file] [--show-all | --show-only list]
65
-
66
- The generator by default will generate five masterview template files, one for each distinct page, list, new, edit, show, and destroy. They exist in the app/views/masterview directory with the filename controller_action.html. The layout and message partial are defined in the list template file and imported into the others. Similarly the new template defines the form partial which is imported into edit, and finally the show file defines a _show partial which is imported into destroy. Thus there is one definition of each part (layout and partial) and they are imported into the other files where needed to provide accurate WYSIWYG design time editing. By generating separate files, teams can work on a project easier, however MasterView also supports generating all parts to a single file for the ultimate in DRY.
67
-
68
- By adding the --single-file switch MasterView will create a single file and to make it easier to use this template at design time, some design time css stylesheets are included in the file to hide all sections except one. By default the NEW section is the only one shown. Other options are --show-all which makes all sections visible or [--show-only list] which shows only the LIST section. When you are editing the masterview file you may comment/uncomment one of the other css files to show a different section. The --style param allows you to suppress default style generation and specify an existing stylesheet to use, if you exlude the stylesheet none will be used, if you include this option multiple times with different stylesheets each will be used.
69
-
70
- Once it is done generating, the generated MasterView template file(s) will be created in app/views/masterview/. These files are html and can be edited with any standard html editor. The rails specific logic is contained in simple attributes which are ignored by html editors. The syntax for these attributes is heavily derived from the rails helper tags themselves so it should feel natural to the rails developer.
71
-
72
- Another interesting thing to know is that while all of the pages for this Model have been bundled up into a few html file for ease of editing, at runtime these templates gets rendered into the exact same layouts and partials that you would use if you were building from scratch. Its jsut that now you can see what your pages will render like in your wysiwyg html editor and change and layout accordingly. Additionally MasterView supplies some javascript to show only one action view at time (list, new, show, edit, destroy) so you can view in your browser without running in Rails. Dummy html can be included to improve the accuracy of the page which can be easily removed at runtime. To make it easier to work with in an editor, design time stylesheets are included in the file to allow you to hide all sections except the one you are working on, simply uncomment the appropriate stylesheet for the section you would like to work with.
73
-
74
- MasterView is designed to be easy for a developer and designer to work together. By keeping the template in an html friendly format, designers can apply style, layout changes, wording changes, without causing havoc on the rails view code. The designer can be involved at anytime during the development cycle including being able to change style and layout after the system is built. This is great for allowing design or wording changes without reinvolving the developers. One can even start from a designer created prototype and add MasterView tags to make it become real. Whichever way you prefer to work, MasterView accomodates you.
75
-
76
- With Version 0.1.0 a MasterView admin controller/view was added to provide a birds-eye view of all your masterview templates, the status of those templates (OK, Invalid xhtml, Conflicts, Imports outdated), the details regarding the status, and the ultimate erb files generated from each template. By default the MasterView admin controller is enabled by the plugin and is available at http://yourserver/masterview This controller can easily be disabled if not wanted by setting the EnableMasterViewAdminPages = false in the vendor/plugins/masterview/init.rb file. Additionally all of the power of the MasterView admin controller is available via a set of rake commands as well. rake mv:list mv:list_all mv:rebuild mv:rebuild_all mv:copy_layout. rake -T will give you further information about these commands.
77
-
78
- Since it can be difficult to import a layout by hand into a new file, the MasterView admin controller has a link where you can copy the layout into a new file by providing the new files Action. It will take the layout from the template chosen and create a new file controller_action.html with the layout imported and a shell for the new Action code. You can also do this from command line using rake mv:copy_layout TEMPLATE=foo_list.html ACTION=newaction command.
79
-
80
- == MasterView attribute directive syntax
81
-
82
- These attribute directives are provided by MasterView and you can create your own custom attributes for even more power.
83
-
84
- mv:generate="layouts/product.rhtml"
85
- When the generate directive is encountered it creates a new output rhtml file where this element and its
86
- children will be rendered. It also will suspend outputting to any previous output file until it is done with this
87
- one (nested). MasterView will not output any rhtml files unless it encouters one of these or mv:gen_render directive
88
- below. Typically you will have one of these in the very top html element to generate the layout, and you will have
89
- additional directives further inside to output different view partials and forms. MasterView takes this one html
90
- file and generates all the other layout, forms, and partials that you would do manually. for example...
91
-
92
- <html mv:generate="layouts/product.rhtml">
93
- <title>Hello</title>
94
- <body>
95
- <div mv:replace="@content_for_layout">
96
- <div mv:generate="product/new.rhtml">
97
- <form></form>
98
- </div>
99
- </div>
100
- </body>
101
- </html>
102
-
103
- outputs to two files
104
-
105
- app/views/layouts/product.rhtml
106
- <html>
107
- <title>Hello</title>
108
- <body>
109
- <%= @content_for_layout %>
110
- </body>
111
- </html>
112
-
113
- app/views/product/new.rhtml
114
- <div>
115
- <form></form>
116
- </div>
117
-
118
- mv:import="layouts/product.rhtml"
119
- When the import directive is used, it is a mirror image of the generate directive, except that this directive
120
- doesn't generate any output, it is only used for design time editing. The code inside this tag represents a point
121
- in time capture of the real generated code and if it ever gets out of sync it can easily be sync'd back up by
122
- visiting the MasterView admin page or using rake mv:rebuild_all
123
-
124
- mv:gen_render=":partial => 'product/form'"
125
- This directive does two things it creates a partial and it outputs the appropriate code to render this
126
- partial in the parent output file before beginning output of the partial. It calculates the file name from the
127
- :partial value and appends .rhtml for example...
128
-
129
-
130
- <html mv:generate="layouts/product.rhtml">
131
- <body>
132
- <div mv:gen_render=":partial => 'product/show'">
133
- Name: <span class="static" mv:content="h @product.send(:name)">product Name dummy text</span>
134
- Description: <span class="static" mv:content="h @product.send(:description)">product description dummy text</span>
135
- </div>
136
- </body>
137
- </html>
138
-
139
- outputs two files
140
-
141
- app/views/layouts/product.rhtml
142
- <html>
143
- <body>
144
- <%= render :partial => 'product/show' %>
145
- </body>
146
- </html>
147
-
148
- app/views/product/_show.rhtml
149
- <div>
150
- Name: <span class="static"><%= h @product.send(:name) %></span>
151
- Description: <span class="static"><%= h @product.send(:description) %></span>
152
- </div>
153
-
154
- You can also use collections with your partials like
155
-
156
- <div mv:gen_render=":partial => 'shared/product', :collection => @products">
157
-
158
- which will create the partial shared/_product.rhtml and will render this partial over a collection
159
-
160
- mv:import_render="partial => 'product/form'"
161
- Similar to how import directive is a mirror to generate, import_render is a mirror to gen_render. This directive
162
- generates the appropriate render partial helper, but doesn't generate any additional output, it is only used for
163
- design time editing and can be easily sync'd up if it ever gets out of sync with the original code.
164
-
165
- mv:gen_replace="whatToLeave"
166
- When used in conjunction with mv:generate directive it causes the value of the attribute to be erb
167
- executed output in the parent file before transferring to the child (nested) output file. for example...
168
-
169
- <html mv:generate="layouts/product.rhtml">
170
- <title>Hello</title>
171
- <body>
172
- <div mv:generate="product/new.rhtml" mv:gen_replace="@content_for_layout>
173
- <form></form>
174
- </div>
175
- </body>
176
- </html>
177
-
178
- outputs two files
179
-
180
- app/views/layouts/product.rhtml
181
- <html>
182
- <title>Hello</title>
183
- <body>
184
- <%= @content_for_layout %>
185
- </body>
186
- </html>
187
-
188
- app/views/product/new.rhtml
189
- <div>
190
- <form></form>
191
- </div>
192
-
193
- mv:attr=":foo => 'bar', :cat => #{h product.name}"
194
- At runtime this sets attribute values on the element this directive is defined on, for example...
195
-
196
- <div mv:attr=":foo => 'bar', :hi => 'cat'">hello</div>
197
-
198
- becomes
199
-
200
- <div foo="bar" hi="cat">hello</div>
201
-
202
- You can put erb evaluated code in #{ } like in this example
203
-
204
- <div mv:attr=":foo => #{h product.name}, :hi => 'cat'">hello</div>
205
-
206
- becomes
207
-
208
- <div foo="<%= h product.name %>" hi="cat">hello</div>
209
-
210
- mv:block="rubyBlockCodeHere"
211
- At runtime this expands to the equivalent rhtml (erb) block code around this element, for example...
212
-
213
- <div mv:block="products.each do |product|">foobar</div>
214
-
215
- becomes
216
-
217
- <% products.each do |product| %>
218
- <div>foobar</div>
219
- <% end %>
220
-
221
- Note how MasterView automatically put in the 'end' after the closing tag.
222
- Another example using the brace form of a block
223
-
224
- <div mv:block="products.each { |product|">foobar</div>
225
-
226
- becomes
227
-
228
- <% products.each { |product| %>
229
- <div>foobar</div>
230
- <% } %>
231
-
232
- Its all based on the ruby and rails syntax while keeping things xhtml and designer friendly.
233
-
234
- mv:content="foo"
235
- Replaces the content of the tag with the erb output of foo, for example...
236
-
237
- <div mv:content="foo">some dummy html here</div>
238
-
239
- becomes
240
-
241
- <div><%= foo %></div>
242
-
243
- mv:form=":action => 'new'"
244
- Replaces this tag and closing tag with the form_tag and end_form_tag helpers. It also pulls the
245
- method and multipart attributes from the element and merges that into the form_tag options, for example...
246
-
247
- <form mv:form=":action => 'new'">foobar</form>
248
-
249
- becomes
250
-
251
- <% form_tag :action => 'new' %>
252
- foobar
253
- <% end_form_tag %>
254
-
255
- <form method="GET" mv:form=":action => 'new'">foobar</form>
256
-
257
- becomes
258
-
259
- <% form_tag { :action => 'new' }, :method => 'GET' %>
260
- foobar
261
- <% end_form_tag %>
262
-
263
- mv:hidden_field="object, method"
264
- Replaces this tag with an hidden input tag using the rails hidden_tag helper, for example...
265
-
266
- <input mv:hidden_field="product, desc" type="hidden" value="dummy text"/>
267
-
268
- becomes
269
-
270
- <%= hidden_field product, desc %>
271
-
272
- mv:if="yourIfConditionHere"
273
- Wraps the tag with an if block using the attribute contents for the condition, for example...
274
-
275
- <div mv:if="@flash[:notice]">foo</div>
276
-
277
- becomes
278
-
279
- <% if @flash[:notice] %>
280
- <div>foo</div>
281
- <% end %>
282
-
283
- And combining if and content directives we can do the following
284
-
285
- <div mv:if="@flash[:notice]" mv:content="@flash[:notice]" class="messages">
286
- dummy notice message here
287
- </div>
288
-
289
- becomes
290
-
291
- <% if @flash[:notice] %>
292
- <div>
293
- <%= @flash[:notice] %>
294
- </div>
295
- <% end %>
296
-
297
- mv:elsif="yourElseConditionHere"
298
- Used in conjunction with an if directive allows you to create if, elsif blocks, for example...
299
-
300
- <div mv:if="foo()">
301
- hello
302
- </div>
303
- <div mv:elsif="bar()">
304
- world
305
- </div>
306
-
307
- becomes
308
-
309
- <% if foo() %>
310
- <div>
311
- hello
312
- </div>
313
- <% elsif bar() %>
314
- <div>
315
- world
316
- </div>
317
- <% end %>
318
-
319
- Note that the elsif directive element needs to follow the if element's closing tag
320
-
321
- mv:else=""
322
- Used in conjunction with if and elsif, allows you to create if, elseif, else blocks, for example...
323
-
324
- <div mv:if="@foo">
325
- hello
326
- </div>
327
- <div mv:else="">
328
- world
329
- </div>
330
-
331
- becomes
332
-
333
- <% if @foo %>
334
- <div>
335
- hello
336
- </div>
337
- <% else %>
338
- <div>
339
- world
340
- </div>
341
- <% end %>
342
-
343
- mv:javascript_include="prototype.js"
344
- Replaces the tag with a javascript_include_tag helper, for example...
345
-
346
- <script type="text/javascript" src="../../../public/javascripts/prototype.js"
347
- mv:javascript_include="prototype.js"></script>
348
-
349
- becomes
350
-
351
- <%= javascript_include_tag 'prototype.js' %>
352
-
353
- This is useful to allow scripts to be used for demos/prototypes and then at runtime
354
- use the appropriate asset using the rails helper.
355
-
356
- mv:link_to="linkToOptions"
357
- Replaces the tag with a link_to helper, it uses the contents of the tag for the name of the link,
358
- so the name of the link can be changed by the html designer and it gets used in the appropriate place
359
- in the helper, for example...
360
-
361
- <a mv:link_to=":action => 'new'">New product</a>
362
-
363
- becomes
364
-
365
- <%= link_to 'New product', :action => 'new' %>
366
-
367
- mv:link_to_if="linkToIfConditionAndOption"
368
- Replaces the tag with a link_to_if helper, uses the contents of the tag for the name of the
369
- link so the name of the link can be changed by the html designer and it gets used in the appropriate
370
- place in the helper, for example...
371
-
372
- <a mv:link_to_if="@product_pages.current.previous, { :page => @product_pages.current.previous }"Previous page"</a>
373
-
374
- becomes
375
-
376
- <%= link_to_if @product_pages.current.previous, 'Previous page', {:page => @product_pages.current.previous } %>
377
-
378
- mv:link_to_remote="linkToRemoteOptions"
379
- Replaces the tag with a link_to_remote helper, uses the contents of the tag for the name of the
380
- link so the name of the link can be changed by the html designer and it gets used in the appropriate
381
- place in the helper, for example...
382
-
383
- <a mv:link_to_remote=":action => 'new'">New product</a>
384
-
385
- becomes
386
-
387
- <%= link_to_remote 'New product', :action => 'new' %>
388
-
389
- mv:omit_tag="evalString"
390
- Omit the element tag if the evalString is empty or evaluates to true. For example...
391
-
392
- <span mv:omit_tag="">hello</span>
393
-
394
- becomes
395
-
396
- hello
397
-
398
- <span mv:omit_tag="@test">hello</span>
399
-
400
- becomes
401
-
402
- <% if @test %><span><% end %>hello<% if @test %></span><% end %>
403
-
404
-
405
- mv:password_field="user, password"
406
- Replaces the tag with a password_field helper using the attribute as well as merging any html
407
- attributes that have been set by the designer, for example...
408
-
409
- <input type="password" mv:password_field="user, password"/>
410
-
411
- becomes
412
-
413
- <%= password_field user, password %>
414
-
415
- and similarly
416
-
417
- <input type="password" mv:password_field="user, password" size="10" maxlength="15" class="pwdStyle"/>
418
-
419
- becomes
420
-
421
- <%= password_field, user, password, :class => 'pwdStyle', :maxlength = 15, :size => 10 %>
422
-
423
- mv:replace="foo bar"
424
- Replaces the tag and contents with the erb executed output of the attribute. If the attribute
425
- value is an empty string then the tag is simply removed and nothing is output, for example...
426
-
427
- <span mv:replace="h product.name">dummy product name</span>
428
-
429
- becomes
430
-
431
- <%= h product.name %>
432
-
433
- and similarly, you can use this to remove dummy html which was there for prototyping/demoing
434
-
435
- <table>
436
- other rows here
437
- <tr mv:replace="">
438
- <td>foo</td>
439
- <td>bar</td>
440
- </tr>
441
- </table>
442
-
443
- becomes
444
-
445
- <table>
446
- other rows here
447
- </table>
448
-
449
- Passing in an empty attribute simply eliminated the tag, children, and contents
450
-
451
- mv:stylesheet_link="style"
452
- Replaces the tag with a stylesheet_link_tag helper, for example...
453
-
454
- <link rel="stylesheet" type="text/css" href="../../../public/stylesheets/scaffold.css" mv:stylesheet_link="scaffold"/>
455
-
456
- becomes
457
-
458
- <%= stylesheet_link_tag "scaffold" %>
459
-
460
- This is useful to allow style to be used for demos/prototypes and then at runtime
461
- use the appropriate asset using the rails helper.
462
-
463
- mv:submit="submitOptions"
464
- Replaces the tag with a submit_tag helper, it uses the html value attribute to set the text
465
- in the helper, and appends any options after, for example...
466
-
467
- <input type="submit" mv:submit="" value="Save product"/>
468
-
469
- becomes
470
-
471
- <%= submit_tag 'Save product' %>
472
-
473
- and
474
-
475
- <input type="submit" mv:submit=":foo => 'bar'" value="Save product"/>
476
-
477
- becomes
478
-
479
- <%= submit_tag 'Save product', :foo => 'bar' %>
480
-
481
-
482
- mv:text_area="object, method"
483
- Replaces the tag with a text_area helper, it uses the html attributes like rows, cols, disabled,
484
- readonly, class, style, tabindex, accesskey and merges them with the object and method specified
485
- in the attribute value, for example...
486
-
487
- <textarea mv:text_areas="product, desc">dummy text</textarea>
488
-
489
- becomes
490
-
491
- <%= text_area prouct, desc %>
492
-
493
- or a more complex example
494
-
495
- <textarea mv:text_area="product, desc" rows="4" cols="60", class="mystyle">dummy text</textarea>
496
-
497
- becomes
498
-
499
- <%= textarea product, desc, :class => 'mystyle', :cols => '60', :rows => 4 %>
500
-
501
- mv:text_field="object, method"
502
- Replaces the tag with a text_field helper, it uses the html attributes like size, maxlength,
503
- disabled, readonly, class, style, tabindex, accesskey and merges them with the object and
504
- method specified in the attribute value, for example...
505
-
506
- <input type="text" mv:text_field="product, name" value="dummy text"/>
507
-
508
- becomes
509
-
510
- <%= text_field product, name %>
511
-
512
- and
513
-
514
- <input type="text" mv:text_field="product, name" value="dummy text" class="mystyle" size="15" maxlength="20"/>
515
-
516
- becomes
517
-
518
- <%= text_field product, name, :class => 'mystyle', :maxlength => 20, :size => 15 %>
519
-
520
-
521
-
522
- Inline substitutions
523
- Since <%= foobar %> and <% foo %> are invalid xhtml values, MasterView has an inline substitution to
524
- replace these for the cases when you simply want to inject something. {{{ gets replaced with <%
525
- and {{{= gets replaced with <%= also }}} gets replaced with %> If you instead want to use the
526
- old <% syntax instead, MasterView by default is setup to perform a substitution on those values before
527
- parsing. However to be safe you should use the xhtml safe syntax otherwise html editors might end
528
- up changing things on you.
529
-
530
- {{{= foobar }}}
531
-
532
- becomes
533
-
534
- <%= foobar %>
535
-
536
-
537
- and
538
-
539
- {{{ foo }}}
540
-
541
- becomes
542
-
543
- <% foo %>
62
+ The MasterView User's Guide and a complete Directives Reference are provided
63
+ in the MasterView user documentation. MasterView templates can be
64
+ created by hand simply by adding masterview directives markup to
65
+ an (x)html template, or generated for typical Rails controller/view
66
+ scenarios using the supplied masterview generator developer tool.
544
67
 
68
+ A MasterView Admin controller can optionally be activated in your application
69
+ to assist you during development with creating and managing your templates.
545
70
 
546
71
  == Background story
547
72
 
@@ -586,8 +111,10 @@ structures to pass to the templates) as so many of the other engines relied on.
586
111
  I expanded my search outside of Ruby for the best html template technology I could find.
587
112
  After reviewing all the front runners I still didn't find anything that quite met with my
588
113
  goals for developing with ruby and rails. I also didn't find any technology that was
589
- close enough that I could adapt it. However I did come across features in a variety of
590
- systems that inspired me, and helped me shape the ideas that are presented here.
114
+ close enough that I could adapt it. However I did come across features in a variety of
115
+ systems that inspired me, and helped me shape the ideas that are presented here.
116
+ A few of those systems were Tapestry, Zope/PHP TAL, Kwartz, Amrita 2, Liquid,
117
+ and Web Objects.
591
118
 
592
119
  After putting much thought into all the possible options I could not see extending
593
120
  an existing template engine to meet my needs. And since I wanted this engine to have
@@ -614,6 +141,12 @@ thank God for bringing the right people into my life just when I needed them and
614
141
  bringing me on this wonderful journey, I am so very blessed. May I be able to give
615
142
  back some of what has been given to me.
616
143
 
144
+ And one more mention of tremendous thanks to Deb Lewis, the other core developer on the
145
+ team, she has spent countless hours reviewing, revising, and improving the codebase,
146
+ configuration, and documentation. The project wouldn't be half of what it is today
147
+ without all her help, inspiration, and hard work. I thoroughly enjoy working and
148
+ debating the finer points of the project with her each step of the way.
149
+
617
150
  So that's the story, I hope that many of you will find MasterView to be a useful
618
151
  tool for your development. I am continuing to refine MasterView by using it daily for
619
152
  Genesis Ministry sites and all my web projects. I know that there is much more work needed
@@ -622,4 +155,3 @@ appreciate any feedback and ideas that you have. Thanks for taking the time to
622
155
  review MasterView!
623
156
 
624
157
  Jeff Barczewski (jeff.barczewski @ gmail.com)
625
-