Deb Lewis
2006-Jun-02 22:29 UTC
[Masterview-devel] On target patterns in mv:generate attributes
[long discussion of what''s actually a pretty simple notion - could be useful input to docs as a howto recipe, e.g., "so you just want to get a simple set of html pages into rails views without having to turn your pages into disembodied .rhtml fragments"] The issue: a lot of template files are simple wrappers around a chunk of content intended to go into a page view within a nice rails layout which provides standard header/sidebar framing in the site. The MasterView template gives me a complete, legal (x)HTML document to edit and view at design time, possibly with placeholder framing for the headers and sidebars that gets filled in by the rails app layout in the real site; the main body of the template is now nicely wrapped for development editing and destined for an rhtml file in app/views so it can get into the layout''s <%@content_for_layout %> slot in the usual rails rendering fashion. e.g., template foo.html is something like: <html ...><head>...</head> <body> <div>Note to self: page header banner and general nav features will go here</div> <div mv:generate="foo.rhtml" mv:omit_tag=""> ... page content for foo.rhtml goes here .... </div> </body> </html> Now, I really hate creating a bunch of templates which require that I repeat the template''s file name (and subdirectory structure) within that file in the mv:generate attribute. If I change the name or reorganize the directories, I have to change both the file system *and* the content. Fails to achieve the DRY principle. So I want a notation in the mv:generate attribute value which makes it simple to specify "use the relative path of this template file within the template source directory as the generated file''s relative path". And I probably don''t want to have to write ".rhtml" in every one of these, either, so the notation should allow for "and replace the template file extension (ordinarily ''.html'') with erb''s usual .rhtml file extension" [or an extension specified by the MasterView::Configuration, if customization is needed] Some notational possibilities: mv:generate="" mv:generate="*" mv:generate="{this_page}" mv:generate="{this_ref}" mv:generate="{rel_ref}" mv:generate="{template_ref}" mv:generate="*.rhtml" mv:generate="{template_ref}.rhtml" Considerations: - concise - keep it short and simple - clear - notation should communicate the intent to someone working directly with the template markup, not leave them scratching their head in befuddlement - allow for the possibility that in the future we might want to provide some pattern-matching notations in this attribute to specify transformations on the template file''s relative path - possibly some RE notation to express a transformation of the originating file''s reference within the template directory space. ~ Deb