diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2006-05-02 09:52:00 +0000 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2006-05-02 09:52:00 +0000 |
commit | 118f9b3afb9cc26fd64fae6924c8b3b4742eb96f (patch) | |
tree | 9fdb507fd2571966973a95e7d8be08202946ea9b /lib/erubis/enhancer.rb | |
parent | 4a07bdcfb44988a464a3abaa9e80fc43bbde00a8 (diff) | |
download | erubis-118f9b3afb9cc26fd64fae6924c8b3b4742eb96f.tar.gz |
- [refactor] Engine#compile() refactored
- [refactor] XxxxXmlEruby classes are removed
- [change] PrintStatementEnhancer is renamed to PrintOutEnhancer
- [change] add benchmark/erubybench-lib.rb
- [change] command-line option '-E' (enhancers) changed to '-e'
- [change] README is rewrited in RDoc format
- [change] removed FastEnhancer
- [change] removed XxxXmlEruby classes
- [enhance] new command-line option '-E' (show all enhancers)
- [enhance] add XxxEnhancer.desc
Diffstat (limited to 'lib/erubis/enhancer.rb')
-rw-r--r-- | lib/erubis/enhancer.rb | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/lib/erubis/enhancer.rb b/lib/erubis/enhancer.rb index ae5ea28..cbcecdb 100644 --- a/lib/erubis/enhancer.rb +++ b/lib/erubis/enhancer.rb @@ -23,6 +23,10 @@ module Erubis ## module EscapeEnhancer + def self.desc # :nodoc: + "switch '<%= %>' to escaped and '<%== %>' to unescaped" + end + #-- #def self.included(klass) # klass.class_eval <<-END @@ -50,9 +54,11 @@ module Erubis end + #-- ## (obsolete) - module FastEnhancer - end + #module FastEnhancer + #end + #++ ## @@ -62,6 +68,10 @@ module Erubis ## module StdoutEnhancer + def self.desc # :nodoc: + "use $stdout instead of array buffer or string buffer" + end + def add_preamble(src) src << "_out = $stdout;" end @@ -74,11 +84,15 @@ module Erubis ## - ## use print statement instead of '_out << ...' style + ## use print statement instead of '_out << ...' ## ## this is only for Eruby. ## - module PrintStatementEnhancer + module PrintOutEnhancer + + def self.desc # :nodoc: + "use print statement instead of '_out << ...'" + end def add_preamble(src) end @@ -116,6 +130,10 @@ module Erubis ## module PrintEnabledEnhancer + def self.desc # :nodoc: + "enable to use print statement in '<% %>'" + end + def add_preamble(src) src << "@_out = " super @@ -137,6 +155,10 @@ module Erubis ## module ArrayEnhancer + def self.desc # :nodoc: + "return array instead of string" + end + def add_preamble(src) src << "_out = [];" end @@ -150,12 +172,16 @@ module Erubis ## - ## use array buffer instead of string buffer + ## use array buffer instead of string buffer (included in Eruby by default) ## ## this is only for Eruby. ## module ArrayBufferEnhancer + def self.desc # :nodoc: + "use array buffer instead of string (included in Eruby by default)" + end + def add_preamble(src) src << "_out = [];" end @@ -175,6 +201,10 @@ module Erubis ## module StringBufferEnhancer + def self.desc # :nodoc: + "use string buffer instead of array buffer" + end + def add_preamble(src) src << "_out = '';" end @@ -188,13 +218,15 @@ module Erubis ## - ## simple and minimum compiler engine - ## - ## this makes compile faster, but spaces around '<%...%>' are not trimmed. + ## get compile faster, but spaces around '<%...%>' are not trimmed. ## ## this is language-independent. ## - module SimplifiedEnhancer + module SimplifyEnhancer + + def self.desc # :nodoc: + "get compile faster but leave spaces around '<% %>'" + end #DEFAULT_REGEXP = /(.*?)(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m SIMPLE_REGEXP = /(.*?)<%(=+|\#)?(.*?)-?%>/m @@ -255,6 +287,10 @@ module Erubis ## module BiPatternEnhancer + def self.desc # :nodoc: + "another embedded expression pattern (default '\[= =\]')." + end + def initialize(input, properties={}) self.bipattern = properties[:bipattern] # or '\$\{ \}' super @@ -281,7 +317,7 @@ module Erubis ## - ## enable to use ruby statement line starts with '%' + ## regards lines starting with '%' as program code ## ## this is for compatibility to eruby and ERB. ## @@ -289,6 +325,10 @@ module Erubis ## module PercentLineEnhancer + def self.desc # :nodoc: + "regard lines starting with '%' as program code" + end + PERCENT_LINE_PATTERN = /(.*?)^\%(.*?\r?\n)/m def add_text(src, text) @@ -359,6 +399,10 @@ module Erubis ## module HeaderFooterEnhancer + def self.desc # :nodoc: + "allow header/footer in document (ex. '<!--#header: #-->')" + end + HEADER_FOOTER_PATTERN = /(.*?)(^[ \t]*)?<!--\#(\w+):(.*?)\#-->([ \t]*\r?\n)?/m def add_text(src, text) |