#!/usr/bin/env ruby #-- # Copyright (c) 2006 Jeff Barczewski # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ # # = MasterView - Rails-optimized (x)html friendly template engine # # MasterView is a ruby/rails optimized HTML/XHTML friendly template engine. # It is designed to use the full power and productivity of rails including # layouts, partials, and rails html helpers while still being editable/styleable # in a WYSIWYG HTML editor. $LOAD_PATH.unshift(File.dirname(__FILE__)) module MasterView # set to true to have exceptions rescued RescueExceptions = false # :tidy - run tidy before parsing (set TidyPath), :escape_erb - escapes <% %> before parsing DefaultParserOptions = { :tidy => false, :escape_erb => true } # paths to load directives from, append your own paths to load custom directives DefaultDirectiveLoadPaths = [ File.join( File.dirname(__FILE__), 'masterview/directives') ] # prefix attributes in html with this value NamespacePrefix = 'mv:' # relative path under RAILS_ROOT/app/views where masterview templates are loaded TemplateSrcRelativePath = 'masterview' # masterview template filename pattern TemplateFilenamePattern = '*.html' # relative path to RAILS_ROOT/app/views where erb (rhtml) will be generated TemplateDestRelativePath = '' # boolean which determines whether warning comments will be ommitted (not generated) in rhtml indicating # the generated file should not be manually edited, false = generate the warning comments OmitGeneratedComments = false # boolean which determines whether masterview files will be parsed during rails load and watched on requests. # If true then masterview files will be parsed on rails loading. Additionally if # this is true and the ActionController::Base.perform_caching is false (normally in development mode) # then the masterview files will again be checked (using modified time) to see if any files need to # be re-parsed. In production mode ActionController::Base.perform_caching is normally true and thus # masterview files will only be parsed on first load. # If this constant is set to false then no automatic watching or parsing occurs, it would be assumed # that the parsing would have been manually triggered prior. AutoParseMasterViewFiles = true # xhtml safe substitution for '<%', make sure to update InlineErbSubstitutionRegex if changed InlineErbStart = '{{{' # xhtml safe substitution for '%>', make sure to update InlineErbSubstitutionRegex if changed InlineErbEnd = '}}}' # regex used to find escaped InlineErb, needs to match InlineErbStart and InlineErbEnd InlineErbSubstitutionRegex = /\{\{\{(([^}]|\}[^}]|\}\}[^}])*)\}\}\}/ # sets path to tidy library on this system so masterview templates will be first run through tidy before parsing, # required if DefaultParserOptions :tidy => true # This allows invalid xhtml to be corrected before parsing TidyPath = '/usr/lib/libtidy.so' end #external requires require 'rexml/parsers/sax2parser' require 'rexml/sax2listener' require 'cgi' require 'fileutils' require 'strscan' #external gem requires require 'facets/core/string/blank' require 'facets/core/string/indent' require 'facets/core/string/starts_with' #optional external gem requires, added functionality when available require 'log4r' require 'tidy' #internal requires require 'masterview/masterview_version' require 'masterview/string_extensions' require 'masterview/plugin_load_tracking' require 'masterview/directive_helpers' require 'masterview/directive_base' require 'masterview/runtime_helpers' require 'masterview/parser' include MasterView::RuntimeHelpers # set these constants after everything has been required module MasterView DefaultSerializer = FileSerializer # setup logger begin include Log4r # will use log4r if available, otherwise default to logger # Logger which will be used to output debug, warn, and error messages, will use log4r if available, otherwise logger Log = Logger.new 'MasterView' Log.outputters = Outputter.stdout rescue # else fallback to built in logger require 'logger' Log = Logger.new STDOUT # :nodoc: end end