[Masterview-devel] On default config values for dir locations (templates, directives)

Deb Lewis djlewis at acm.org
Wed Jun 7 13:28:56 EDT 2006

Jeff - some thoughts on some of the current default config settings for key
locations that MV deals with.

[long, this is kind of a "thinking out loud" msg to elaborate some

Current MV config defaults:

- template source directory;
   - rails app: app/views/masterview
   - non-rails config: not sure if there's a good default assumption
      [I put in './masterview/templates' for now...]

- template output directory:
    - rails app: app/views
    - non-rails config: nil - client needs to say what they want

- directives load path:
    - initialized to load mv built-in directives:
        [ "#{MV_LIB_DIR}/masterview/directives' ]

I'm now quite happily in the process of converting some content pages for a
site that I'm moving onto rails into masterview templates.  This is a
relatively simple use case scenario: mainly wrapping some existing, fairly
static content in MV templates with mv:generate="*" specs to spit out body
content into an .rhmtl for the <%= @content_for_layout %> slot in the rails
site's layout.  Some lightweight usage of mv/rails facilities (mv:attr to
map some hrefs between ref in my template sandbox to how the urls look in
the real site).

Aside from still needing to settle on notation for mv:generate to provide
"magic values" ("*" or "#{template_rel_ref}" or a pythonic-style
"__template_rel_ref_" or ...) or var subst for target path, I'm quite happy
with how this works.  MV lets me create content pages as complete, valid
xhtml docs and supports declarative-style markup using the mv: attributes.
Very nice.

But I've gone through several variations of "where do I want to keep my
template files" over the past week, partly just to play with the mechanisms
and test things.  I've used:

    app/views/masterview - the default config
    app/mv-templates - sibling structure which maps output into app/views

[and not tried but might consider: app/views/masterview/templates - fits in
with the MasterviewController structure]

I somewhat prefer the sibling dir alongside app/views over the current
default w/in the views dir - I like the symmetry of the parallel structure,
rather than pushing masterview templates into a somewhat odd,
not-used-in-quite-the-usual-fashion area within app/views.

But what I've actually settled on, which what I wanted in the first place
and is the right structure in the long run:

    app/views - MV .html templates live right where they belong

The fact that generated .rhtml files appear alongside my .html templates is
simply an artifact of the current MV implementation.  Someday (*), the
.rhtml intermediate files won't need to be there - a view ref that maps onto
a MV template will do the same magic compile-on-the-fly and caching that
rails does now for its .rhtml files.

(*) maybe even soon, because I can begin to see a way to do this, at least
for this simple scenario where there aren't inter-template generate/import

After first pass to settle the basic structure in my site, I now see an
opportunity to use a custom directive to simplify some annoying markup
redundancy in the original static impl.  I'm going to give that a try and if
it works out it'll be a good example to deliver with MV.  Specific case is
that I have a number of pages which are just indexes to report files and
each report link has a little document icon indicating the form of the
report (an html view or a printable view or a PDF file).  So a little
icon_for_link directive would be a really handy gadget for this site.

All of which is the rationale leading into other thought on MV config
defaults: believe it would be useful for the default config for a rails
application to have a point of view on where it might find app-specific
directives to automatically load.  If app dir's directory exist, append to
config.directive_paths after the MV built-ins.

Not sure putting directives code in config/masterview/directives is the
right place.  Possible app/masterview/directives; possibly
app/lib/masterview/directives is better (but need to review rails loading
magic to see if that would work, don't want rails itself to auto-load things
in there)

Opinion?  I hypothesize that the empty directives dir in the masterview
trunk was your notion for providing a convention for this, but don't think
that's the right place.

~ Deb

More information about the Masterview-devel mailing list