Module: W2Tags
- Defined in:
- lib/w2tags.rb,
lib/w2tags/parser.rb,
lib/w2tags/block/sass.rb,
lib/w2tags/block/remark.rb,
lib/w2tags/block/block_hot.rb,
lib/w2tags/block/plain_text.rb
Overview
W2TAGS (Way to Tags)
W2TAGS is a shortcut of tags, macros, and it is very simple describer for HTML its not to become a replacement for inline tamplating engine, it best use for developement (sinatra / rails / merb) and the result is an “erb” file to be execute by erb or erubis (the fastest templating engine).
It focus on how developer can code and generate dynamic content with DRY philosophy, easy to understand and in a very clean way.
Features
-
Mimics HAML syntax (inherit features define in HAML)
-
Extended syntax for Next Tag, Variable, Constanta
-
HOT file is patern for put in repetitif code and leter can be call it
-
HOT Variable interpolation, make it code really DRY
Using W2TAGS
some of the guide are inside
-
README.rdoc
-
doc/W2TAGS.rdoc
-
doc/HAML.rdoc
-
doc/FAQ.rdoc
-
doc/HOT.rdoc
Defined Under Namespace
Modules: Block Classes: Parser
Constant Summary collapse
- Dir =
File.dirname(__FILE__)
- VERSION =
File.read(Dir + '/../VERSION').strip
Class Method Summary collapse
- .parsing_hot(src) ⇒ Object
-
.read_filehot(fhot) ⇒ Object
hot files is a collection of w2tags function example of the function that will translate by this method.
-
.splitter(data, deli = ';') ⇒ Object
split string with aditional option escape charaters’'.
Class Method Details
.parsing_hot(src) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/w2tags.rb', line 74 def self.parsing_hot(src) hot_new = {} hot = ("\n"+src).split(/\n\>\>/) hot.shift hot.each do |item| item.gsub!(/\n([ \t]*)$/,'') #remove blank lines ends = item.split(/\n\<\<\/[^\n]*\n/) #hots | ends mems = ends[0].split(/\n\!~[^\n]*\n/) #hots | mems khot = mems[0].split("\n") #key | hot keys = khot.shift.rstrip #hots = mems[0].gsub(keys+"\n",'') hots = khot.join("\n") hot = [nil,nil] hot[0]= proc do |this| this.chg_mem_hot(mems[1]) if this!= nil hots end if ends.size>1 hot[1] = [ends[1]] # tend = splitter(ends[1]) # if tend.size==1 # hot[1] = [tend] # else # hot[1] = tend.collect {|x|"</#{x}>"} # end end hot_new[keys] = hot end hot_new end |
.read_filehot(fhot) ⇒ Object
hot files is a collection of w2tags function example of the function that will translate by this method
>>body
<body>
<</
</body>
and example of use that function
@body()
@div!Hello Tags
./
it will produce
<body>
<div>Hello Tags</div>
</body>
70 71 72 |
# File 'lib/w2tags.rb', line 70 def self.read_filehot(fhot) parsing_hot(IO.read(fhot).delete("\r")) end |
.splitter(data, deli = ';') ⇒ Object
split string with aditional option escape charaters’'
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/w2tags.rb', line 36 def self.splitter(data,deli=';') tg_esc = data.split("\\"+deli) if tg_esc.size > 1 tg_esc = tg_esc.collect {|x|x.split(deli)} result = tg_esc.shift while tg_esc != [] token = tg_esc[0] result[-1,1] = result[-1,1][0] +';'+ token[0,1][0] result = result + token[1,99] tg_esc.shift end else result = data.split(deli) end result end |