README in masterview_gem_pack-0.0.17 vs README in masterview_gem_pack-0.1.0

- old
+ new

@@ -20,11 +20,11 @@ - Create/extend a template engine for rails that would be XHTML friendly and thus could be edited/styled with a WYSIWYG HTML editor even late in development without breaking template. - Keep it simple. DRY. No extra config files, simple syntax with ruby flavor. - Design it specifically for ruby and rails. Use the full power and not be limited in its capabilities over what can be done with ERb - Work nicely with layouts, partials, and rails html helpers. - Reduce complexity, work with existing rails code, no extra view logic or hashes than what is used by ERb. Scaffold generate initial templates or work from existing html prototype. -- Use one master file to drive all related sections, simplifying editing. +- Reduce the numbers of files, simplifying editing. Define partials and layouts naturallyl right in the template, no need to go to another file. - Preview in browser without running an app. Allow for dummy data in the template so that the page can be viewed and styled independently of the application. - Performance equal to ERb == Prerequisites @@ -59,20 +59,26 @@ == Usage 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 -script/generate masterview YourModelName [YourControllerName] [--show-all | --show-only list] [--style [cssStylesheet]] +script/generate masterview YourModelName [YourControllerName] [--style [cssStylesheet]] [--single-file] [--show-all | --show-only list] -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. +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. -Once it is done generating, the generated MasterView template file will be created in app/views/masterview/YourModelName.html. This file is 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. +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. -Another interesting thing to know is that while all of the pages for this Model have been bundled up into one html file for ease of editing, at runtime this template 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, delete) 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. +Once it is done generating, the generated MasterView template file will be created in app/views/masterview/controller.html. This file is 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. +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. + 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. +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. + +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. + == MasterView attribute directive syntax These attribute directives are provided by MasterView and you can create your own custom attributes for even more power. mv:generate="layouts/product.rhtml" @@ -107,10 +113,15 @@ app/views/product/new.rhtml <div> <form></form> </div> +mv:import="layouts/product.rhtml" + When the import directive is used, it is a mirror image of the generate directive, except that this directive + doesn't generate any output, it is only used for design time editing. The code inside this tag represents a point + 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 + visiting the MasterView admin page or using rake mv:rebuild_all mv:gen_render=":partial => 'product/form'" This directive does two things it creates a partial and it outputs the appropriate code to render this partial in the parent output file before beginning output of the partial. It calculates the file name from the :partial value and appends .rhtml for example... @@ -144,10 +155,15 @@ <div mv:gen_render=":partial => 'shared/product', :collection => @products"> which will create the partial shared/_product.rhtml and will render this partial over a collection +mv:import_render="partial => 'product/form'" + Similar to how import directive is a mirror to generate, import_render is a mirror to gen_render. This directive + generates the appropriate render partial helper, but doesn't generate any additional output, it is only used for + design time editing and can be easily sync'd up if it ever gets out of sync with the original code. + mv:gen_replace="whatToLeave" When used in conjunction with mv:generate directive it causes the value of the attribute to be erb executed output in the parent file before transferring to the child (nested) output file. for example... <html mv:generate="layouts/product.rhtml"> @@ -587,7 +603,7 @@ Genesis Ministry sites and all my web projects. I know that there is much more work needed in documentation, examples, test cases, additional directives, etc., so I would appreciate any feedback and ideas that you have. Thanks for taking the time to review MasterView! -Jeff Barczewski (jeff.barczewski @ gmail.com) +Jeff Barczewski (jeff.barczewski @ gmail.com)