w2tags 0.9.3 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -340
- data/LICENSE +6 -6
- data/MIT-LICENSE +18 -18
- data/Manifest.txt +28 -25
- data/README.rdoc +27 -21
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/w2tags +173 -143
- data/doc/History.rdoc +88 -0
- data/hot/erb.hot +18 -156
- data/hot/erb_base.hot +164 -0
- data/hot/html.hot +30 -31
- data/hot/rails/scaffold.hot +15 -15
- data/hot/vm.hot +8 -8
- data/hot/vm2.hot +34 -34
- data/hot/vm_crud.hot +34 -34
- data/hot/vm_popup.hot +74 -74
- data/lib/tags2w.rb +263 -0
- data/lib/w2tags/block/block_hot.rb +37 -0
- data/lib/w2tags/block/plain_text.rb +57 -57
- data/lib/w2tags/block/remark.rb +37 -37
- data/lib/w2tags/block/sass.rb +68 -66
- data/lib/w2tags/merb_hook.rb +15 -15
- data/lib/w2tags/parser.rb +17 -8
- data/lib/w2tags/rails_hook.rb +15 -15
- data/lib/w2tags/sinatra_hook.rb +74 -50
- data/lib/w2tags.rb +100 -100
- data/plugins/{/w2tags/ → w2tags}/README +2 -2
- data/plugins/{/w2tags//generators//w2scaffold/ → w2tags/generators/w2scaffold}/USAGE +29 -29
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/controller.rb +85 -85
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/functional_test.rb +45 -45
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/helper.rb +2 -2
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/helper_test.rb +4 -4
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/layout.html.erb +17 -17
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/style.css +54 -54
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_edit.html.erb +17 -17
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_edit.html.w2erb +16 -16
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_index.html.erb +23 -23
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_index.html.w2erb +13 -13
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_new.html.erb +16 -16
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_new.html.w2erb +15 -15
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_show.html.erb +9 -9
- data/plugins/{/w2tags//generators//w2scaffold//templates/ → w2tags/generators/w2scaffold/templates}/view_show.html.w2erb +8 -8
- data/plugins/{/w2tags//generators//w2scaffold/ → w2tags/generators/w2scaffold}/w2scaffold_generator.rb +106 -106
- data/plugins/{/w2tags/ → w2tags}/install.rb +0 -0
- data/tasks/ann.rake +81 -81
- data/tasks/bones.rake +21 -21
- data/tasks/gem.rake +126 -126
- data/tasks/git.rake +41 -41
- data/tasks/manifest.rake +49 -49
- data/tasks/notes.rake +28 -28
- data/tasks/post_load.rake +39 -39
- data/tasks/rdoc.rake +51 -51
- data/tasks/rubyforge.rake +57 -57
- data/tasks/setup.rb +268 -268
- data/tasks/spec.rake +55 -55
- data/tasks/svn.rake +48 -48
- data/tasks/test.rake +38 -38
- data/test/vars.hot +30 -30
- data/test/w2tags_basic_usability.rb +187 -187
- data/test/w2tags_enlightning.rb +42 -42
- data/test/w2tags_hot.rb +85 -85
- data/test/w2tags_hot_var.rb +115 -115
- metadata +28 -30
data/lib/w2tags/block/sass.rb
CHANGED
@@ -1,66 +1,68 @@
|
|
1
|
-
module W2Tags
|
2
|
-
module Block
|
3
|
-
module Sass
|
4
|
-
def sass_skip_initialize
|
5
|
-
@doc_sas= [] #sass buffer
|
6
|
-
@key_sas= [] #sass indentation
|
7
|
-
@nms_sas= [0,""]
|
8
|
-
@sas = 99 #sass indentation block
|
9
|
-
end
|
10
|
-
|
11
|
-
def sass_skip
|
12
|
-
@rgx = nil
|
13
|
-
if(/(^[\t ]*)(~~~)\n/ =~ @row;@rgx = $~)
|
14
|
-
@row = ''
|
15
|
-
@sas = @spc.size
|
16
|
-
@doc_sas = [[' '*@sas,"<style>\n"].join]
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@
|
22
|
-
@
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
@
|
48
|
-
@
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
1
|
+
module W2Tags
|
2
|
+
module Block
|
3
|
+
module Sass
|
4
|
+
def sass_skip_initialize
|
5
|
+
@doc_sas= [] #sass buffer
|
6
|
+
@key_sas= [] #sass indentation
|
7
|
+
@nms_sas= [0,""]
|
8
|
+
@sas = 99 #sass indentation block
|
9
|
+
end
|
10
|
+
|
11
|
+
def sass_skip
|
12
|
+
@rgx = nil
|
13
|
+
if(/(^[\t ]*)(~~~)\n/ =~ @row;@rgx = $~)
|
14
|
+
@row = ''
|
15
|
+
@sas = @spc.size
|
16
|
+
@doc_sas = [[' '*@sas,"<style>\n"].join]
|
17
|
+
@key_sas = [] #sass indentation
|
18
|
+
@nms_sas = [0,""]
|
19
|
+
elsif @sas!= 99
|
20
|
+
if @spc.size<= @sas
|
21
|
+
@doc_sas<< "#{' '*@key_sas[-1][0]}}\n"
|
22
|
+
@doc_sas<< @doc_sas[0].gsub("<style>","</style>")
|
23
|
+
@doc_out = @doc_out + @doc_sas
|
24
|
+
@sas = 99
|
25
|
+
elsif @row.strip!=''
|
26
|
+
sass_parser
|
27
|
+
end
|
28
|
+
end
|
29
|
+
@sas!=99
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def sass_parser
|
35
|
+
spc= @spc.size
|
36
|
+
if(/(^[\t ]*)(:[\w\-]+) *\n/ =~ @row;@rgx = $~)
|
37
|
+
@nms_sas= [spc,[$1,$2[1,99],"-"].join]
|
38
|
+
elsif(/(^[\t ]*)(:[\w\-]+) +([^\n]+)\n/ =~ @row;@rgx = $~)
|
39
|
+
nms= @nms_sas[0]!=0 && @nms_sas[0]<spc ? @nms_sas[1] : $1
|
40
|
+
@doc_sas << [nms,$2[1,99],":",$3,";\n"].join
|
41
|
+
else
|
42
|
+
old_spc= nil
|
43
|
+
if @key_sas!=[]
|
44
|
+
old_spc = @key_sas[-1][0]
|
45
|
+
@key_sas = @key_sas.select{|l|l[0]<spc} if spc<= old_spc
|
46
|
+
end
|
47
|
+
@key_sas<< [spc,@row.strip]
|
48
|
+
@doc_sas<< [' '*old_spc, "}\n"].join if old_spc
|
49
|
+
@doc_sas<< [@spc,sass_join,"{\n"].join
|
50
|
+
@nms_sas = [0,""]
|
51
|
+
end
|
52
|
+
@row = ''
|
53
|
+
end
|
54
|
+
|
55
|
+
def sass_join
|
56
|
+
rtn= ''
|
57
|
+
@key_sas.each do |line|
|
58
|
+
rtn = (rtn==''? [''] : rtn.split(',')).collect do |p|
|
59
|
+
line[1].split(',').collect do |x|
|
60
|
+
(x.gsub!(/&/,p) ? x : p+' '+ x).strip
|
61
|
+
end.join(',')
|
62
|
+
end.join(',')
|
63
|
+
end
|
64
|
+
rtn
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/w2tags/merb_hook.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
module Merb::Template
|
2
|
-
if Merb.environment != "development"
|
3
|
-
puts 'W2Tags Only RUN on (Merb.environment == "development")'
|
4
|
-
else
|
5
|
-
puts 'W2Tags Hooked on Merb!'
|
6
|
-
W2TAGS = W2Tags::Parser.new
|
7
|
-
class << self
|
8
|
-
def load_template_io(path)
|
9
|
-
src = path.gsub(/\.erb$/,'.w2erb')
|
10
|
-
W2TAGS.parse_file(src,false,true)
|
11
|
-
File.open(path)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
1
|
+
module Merb::Template
|
2
|
+
if Merb.environment != "development"
|
3
|
+
puts 'W2Tags Only RUN on (Merb.environment == "development")'
|
4
|
+
else
|
5
|
+
puts 'W2Tags Hooked on Merb!'
|
6
|
+
W2TAGS = W2Tags::Parser.new
|
7
|
+
class << self
|
8
|
+
def load_template_io(path)
|
9
|
+
src = path.gsub(/\.erb$/,'.w2erb')
|
10
|
+
W2TAGS.parse_file(src,false,true)
|
11
|
+
File.open(path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/w2tags/parser.rb
CHANGED
@@ -12,7 +12,7 @@ module W2Tags
|
|
12
12
|
include *(block.collect{|m|eval("::W2Tags::Block::#{m.to_s}")})
|
13
13
|
#initiall create instance object, default if no arguments will be
|
14
14
|
#target for html
|
15
|
-
def initialize(ext = '
|
15
|
+
def initialize(ext = 'erb')
|
16
16
|
@dbg={
|
17
17
|
:hot =>nil,
|
18
18
|
:stack =>nil,
|
@@ -32,7 +32,6 @@ module W2Tags
|
|
32
32
|
@rgx = nil #current regular expression
|
33
33
|
@ext = ext #target extension
|
34
34
|
@hot = 'hot' #source of file hot
|
35
|
-
@w2x = 'w2x' #source file to include
|
36
35
|
@src_path= '' #path for source file
|
37
36
|
@silent = false #for test
|
38
37
|
|
@@ -317,7 +316,7 @@ module W2Tags
|
|
317
316
|
#v << ';'+@mem_var[k].to_s if v[0,1]!=';' && @mem_var[k]
|
318
317
|
v = (@mem_var[k].to_s + ';' + v) if v[0,1]!=';' && @mem_var[k]
|
319
318
|
@mem_var[k] = v.split(';').uniq.select{|x|x!=''}.join(';')
|
320
|
-
p "
|
319
|
+
p "uniqV> #{v}" if @dbg[:parse] #&& @plt == 99 && @rmk == 99
|
321
320
|
end
|
322
321
|
end
|
323
322
|
|
@@ -347,11 +346,11 @@ module W2Tags
|
|
347
346
|
|
348
347
|
#when parsing and found tag
|
349
348
|
# !inc!fileinc
|
350
|
-
#it will include / replace current row from file
|
349
|
+
#it will include / replace current row from file include, and after
|
351
350
|
#parser will try to get current row after merging to be evaluate
|
352
351
|
def merge_w2x
|
353
352
|
if(/!inc![ ]?([\/\w._]+)([`\n])/ =~ @row;@rgx = $~)
|
354
|
-
mac = @src_path+'/'+$1
|
353
|
+
mac = @src_path+'/'+$1
|
355
354
|
src = $~.to_s #;p mac
|
356
355
|
if File.exist?(mac)
|
357
356
|
pop = $~.captures.pop
|
@@ -438,8 +437,18 @@ module W2Tags
|
|
438
437
|
elsif new_alls==[] && new_prms.size==1 && prms.size>1
|
439
438
|
tmp = ""
|
440
439
|
rpt = @rgx.to_s.gsub(@rgx[3]+"\n","")
|
440
|
+
#multi key params(class,attribute,etc)
|
441
|
+
classs = rpt[/([.:#].*\{.*?\}.*?) /,1]
|
442
|
+
classs = rpt[/(\{.*?\}.*?) /,1] if !classs
|
443
|
+
classs = rpt[/([.:#].*?) /,1] if !classs
|
444
|
+
classs.sub!(/=$/,'') if classs
|
445
|
+
clsmlt = classs.to_s.split(';')
|
446
|
+
clscnt = clsmlt.length
|
441
447
|
prms.each_with_index do |x,i|
|
442
|
-
|
448
|
+
line = rpt+x #tmp<< @new.gsub(new_prms[0],x)
|
449
|
+
#implement multi class params ^.d;.g canggh;bow
|
450
|
+
line.gsub!(classs,(clscnt>i ? clsmlt[i] : '')) if classs
|
451
|
+
tmp<< line
|
443
452
|
tmp<< "\n#{@spc}" if i+1<prms.size
|
444
453
|
end
|
445
454
|
@new = tmp
|
@@ -794,8 +803,8 @@ module W2Tags
|
|
794
803
|
rtn = true if shortcut_exec( /(^[\t ]*)\-([\w\-&\/:#.%=]*) *([^\n]*)\n/)
|
795
804
|
rtn = true if shortcut_equal( /(^[\t ]*)=([\w\-&\/:#.%=]*) *([^\n]*)\n/)
|
796
805
|
|
797
|
-
rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.]+\{
|
798
|
-
rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.]+\{
|
806
|
+
rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.]+\{.*?\}[= ]*)([^\n]*)\n/)
|
807
|
+
rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.]+\{.*?\}[= ]*)()\n/)
|
799
808
|
rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.%=]+ )([^\n]*)\n/)
|
800
809
|
rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.%=]+)()\n/)
|
801
810
|
|
data/lib/w2tags/rails_hook.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
module ActionView
|
2
|
-
if Object::RAILS_ENV != "development"
|
3
|
-
puts 'W2Tags Only RUN on (RAILS_ENV == "development")'
|
4
|
-
else
|
5
|
-
puts 'W2Tags Hooked on Rails 2.3.2 & Up!'
|
6
|
-
class ReloadableTemplate < Template
|
7
|
-
W2TAGS = W2Tags::Parser.new
|
8
|
-
def mtime
|
9
|
-
src = filename.gsub(/\.erb$/,'.w2erb')
|
10
|
-
W2TAGS.parse_file(src,
|
11
|
-
File.mtime(filename)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
1
|
+
module ActionView
|
2
|
+
if Object::RAILS_ENV != "development"
|
3
|
+
puts 'W2Tags Only RUN on (RAILS_ENV == "development")'
|
4
|
+
else
|
5
|
+
puts 'W2Tags Hooked on Rails 2.3.2 & Up!'
|
6
|
+
class ReloadableTemplate < Template
|
7
|
+
W2TAGS = W2Tags::Parser.new
|
8
|
+
def mtime
|
9
|
+
src = filename.gsub(/\.erb$/,'.w2erb')
|
10
|
+
W2TAGS.parse_file(src,true,true)
|
11
|
+
File.mtime(filename)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/w2tags/sinatra_hook.rb
CHANGED
@@ -1,50 +1,74 @@
|
|
1
|
-
module Sinatra
|
2
|
-
if Sinatra::VERSION < '0.9'
|
3
|
-
if Sinatra::Application.default_options[:env] != :development
|
4
|
-
puts 'W2Tags Only RUN on (Sinatra::Application.default_options[:env] == :development)'
|
5
|
-
else
|
6
|
-
puts 'W2Tags Hooked on Sinatra < 0.9.x!'
|
7
|
-
|
8
|
-
module W2TagsHooked
|
9
|
-
W2TAGS = W2Tags::Parser.new
|
10
|
-
def read_template_file(renderer, template, options, scream = true)
|
11
|
-
path = File.join(
|
12
|
-
options[:views_directory] || Sinatra.application.options.views,
|
13
|
-
"#{template}.#{renderer}"
|
14
|
-
)
|
15
|
-
src = path.gsub(path[/(\.\w+)$/,1],'.w2'<<$1[1,9])
|
16
|
-
W2TAGS.parse_file(src,
|
17
|
-
super
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class EventContext
|
22
|
-
include W2TagsHooked
|
23
|
-
end
|
24
|
-
end
|
25
|
-
elsif Sinatra::VERSION > '0.9'
|
26
|
-
|
27
|
-
if Sinatra::Application.environment != :development
|
28
|
-
puts 'W2Tags Only RUN on (Sinatra::Application.environment == :development)'
|
29
|
-
else
|
30
|
-
puts 'W2Tags Hooked on Sinatra > 0.9.x!'
|
31
|
-
|
32
|
-
module W2TagsHooked
|
33
|
-
W2TAGS = W2Tags::Parser.new
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
1
|
+
module Sinatra
|
2
|
+
if Sinatra::VERSION < '0.9'
|
3
|
+
if Sinatra::Application.default_options[:env] != :development
|
4
|
+
puts 'W2Tags Only RUN on (Sinatra::Application.default_options[:env] == :development)'
|
5
|
+
else
|
6
|
+
puts 'W2Tags Hooked on Sinatra < 0.9.x!'
|
7
|
+
|
8
|
+
module W2TagsHooked
|
9
|
+
W2TAGS = W2Tags::Parser.new
|
10
|
+
def read_template_file(renderer, template, options, scream = true)
|
11
|
+
path = File.join(
|
12
|
+
options[:views_directory] || Sinatra.application.options.views,
|
13
|
+
"#{template}.#{renderer}"
|
14
|
+
)
|
15
|
+
src = path.gsub(path[/(\.\w+)$/,1],'.w2'<<$1[1,9])
|
16
|
+
W2TAGS.parse_file(src,true,true)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class EventContext
|
22
|
+
include W2TagsHooked
|
23
|
+
end
|
24
|
+
end
|
25
|
+
elsif Sinatra::VERSION > '0.9'
|
26
|
+
|
27
|
+
if Sinatra::Application.environment != :development
|
28
|
+
puts 'W2Tags Only RUN on (Sinatra::Application.environment == :development)'
|
29
|
+
else
|
30
|
+
puts 'W2Tags Hooked on Sinatra > 0.9.x!'
|
31
|
+
|
32
|
+
module W2TagsHooked
|
33
|
+
W2TAGS = W2Tags::Parser.new
|
34
|
+
if Sinatra::VERSION > '0.9.1'
|
35
|
+
def lookup_template(engine, template, views_dir, filename = nil, line = nil)
|
36
|
+
case template
|
37
|
+
when Symbol
|
38
|
+
if cached = self.class.templates[template]
|
39
|
+
lookup_template(engine, cached[:template], views_dir, cached[:filename], cached[:line])
|
40
|
+
else
|
41
|
+
path = ::File.join(views_dir, "#{template}.#{engine}")
|
42
|
+
src = path.gsub(path[/(\.\w+)$/,1],'.w2'<<$1[1,9])
|
43
|
+
W2TAGS.parse_file(src,true,true)
|
44
|
+
[ ::File.read(path), path, 1 ]
|
45
|
+
end
|
46
|
+
when Proc
|
47
|
+
filename, line = self.class.caller_locations.first if filename.nil?
|
48
|
+
[ template.call, filename, line.to_i ]
|
49
|
+
when String
|
50
|
+
filename, line = self.class.caller_locations.first if filename.nil?
|
51
|
+
[ template, filename, line.to_i ]
|
52
|
+
else
|
53
|
+
raise ArgumentError
|
54
|
+
end
|
55
|
+
end
|
56
|
+
else
|
57
|
+
def lookup_template(engine, template, options={})
|
58
|
+
case template
|
59
|
+
when Symbol
|
60
|
+
path= template_path(engine, template, options)
|
61
|
+
src = path.gsub(path[/(\.\w+)$/,1],'.w2'<<$1[1,9])
|
62
|
+
W2TAGS.parse_file(src,true,true)
|
63
|
+
end
|
64
|
+
super
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Base
|
70
|
+
include W2TagsHooked
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/w2tags.rb
CHANGED
@@ -1,100 +1,100 @@
|
|
1
|
-
dir = File.dirname(__FILE__)
|
2
|
-
Dir["#{dir}/w2tags/block/*.rb"].each{|f|require f}
|
3
|
-
$LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
4
|
-
|
5
|
-
# = W2TAGS (Way to Tags)
|
6
|
-
#
|
7
|
-
# W2TAGS is a shortcut of tags, macros, and it is very simple describer for HTML
|
8
|
-
# its not to become a replacement for inline tamplating engine, it best use for
|
9
|
-
# developement (sinatra / rails / merb) and the result is an "erb" file to be
|
10
|
-
# execute by erb or erubis (the fastest templating engine).
|
11
|
-
#
|
12
|
-
# It focus on how developer can code and generate dynamic content with
|
13
|
-
# DRY philosophy, easy to understand and in a very clean way.
|
14
|
-
#
|
15
|
-
# == Features
|
16
|
-
#
|
17
|
-
# * Mimics HAML syntax (inherit features define in HAML)
|
18
|
-
# * Extended syntax for Next Tag, Variable, Constanta
|
19
|
-
# * HOT file is patern for put in repetitif code and leter can be call it
|
20
|
-
# * HOT Variable interpolation, make it code really DRY
|
21
|
-
#
|
22
|
-
# == Using W2TAGS
|
23
|
-
#
|
24
|
-
# some of the guide are inside
|
25
|
-
# * README.rdoc
|
26
|
-
# * doc/W2TAGS.rdoc
|
27
|
-
# * doc/HAML.rdoc
|
28
|
-
# * doc/FAQ.rdoc
|
29
|
-
# * doc/HOT.rdoc
|
30
|
-
|
31
|
-
module W2Tags
|
32
|
-
Dir = File.dirname(__FILE__)
|
33
|
-
VERSION = File.read(Dir + '/../VERSION').strip unless defined?(VERSION)
|
34
|
-
|
35
|
-
#split string with aditional option escape charaters'\'
|
36
|
-
def self.splitter(data,deli=';')
|
37
|
-
tg_esc = data.split("\\"+deli)
|
38
|
-
if tg_esc.size > 1
|
39
|
-
tg_esc = tg_esc.collect {|x|x.split(deli)}
|
40
|
-
result = tg_esc.shift
|
41
|
-
while tg_esc != []
|
42
|
-
token = tg_esc[0]
|
43
|
-
result[-1,1] = result[-1,1][0] +';'+ token[0,1][0]
|
44
|
-
result = result + token[1,99]
|
45
|
-
tg_esc.shift
|
46
|
-
end
|
47
|
-
else
|
48
|
-
result = data.split(deli)
|
49
|
-
end
|
50
|
-
result
|
51
|
-
end
|
52
|
-
|
53
|
-
#hot files is a collection of w2tags function
|
54
|
-
#example of the function that will translate by this method
|
55
|
-
#
|
56
|
-
# >>body
|
57
|
-
# <body>
|
58
|
-
# <</
|
59
|
-
# </body>
|
60
|
-
#
|
61
|
-
#and example of use that function
|
62
|
-
# @body()
|
63
|
-
# @div!Hello Tags
|
64
|
-
# ./
|
65
|
-
#
|
66
|
-
#it will produce
|
67
|
-
# <body>
|
68
|
-
# <div>Hello Tags</div>
|
69
|
-
# </body>
|
70
|
-
def self.read_filehot(fhot)
|
71
|
-
hot_new = {}
|
72
|
-
hot = ("\n"+IO.read(fhot)).delete("\r").split(/\n\>\>/)
|
73
|
-
hot.shift
|
74
|
-
hot.each do |item|
|
75
|
-
item.gsub!(/\n([ \t]*)$/,'') #remove blank lines
|
76
|
-
ends = item.split(/\n\<\<\/[^\n]*\n/) #hots | ends
|
77
|
-
mems = ends[0].split(/\n\!~[^\n]*\n/) #hots | mems
|
78
|
-
khot = mems[0].split("\n") #key | hot
|
79
|
-
keys = khot.shift.rstrip #hots = mems[0].gsub(keys+"\n",'')
|
80
|
-
hots = khot.join("\n")
|
81
|
-
hot = [nil,nil]
|
82
|
-
hot[0]= proc do |this|
|
83
|
-
this.chg_mem_hot(mems[1]) if this!= nil
|
84
|
-
hots
|
85
|
-
end
|
86
|
-
if ends.size>1
|
87
|
-
hot[1] = [ends[1]]
|
88
|
-
# tend = splitter(ends[1])
|
89
|
-
# if tend.size==1
|
90
|
-
# hot[1] = [tend]
|
91
|
-
# else
|
92
|
-
# hot[1] = tend.collect {|x|"</#{x}>"}
|
93
|
-
# end
|
94
|
-
end
|
95
|
-
hot_new[keys] = hot
|
96
|
-
end
|
97
|
-
hot_new
|
98
|
-
end
|
99
|
-
end
|
100
|
-
require 'w2tags/parser'
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
Dir["#{dir}/w2tags/block/*.rb"].each{|f|require f}
|
3
|
+
$LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
4
|
+
|
5
|
+
# = W2TAGS (Way to Tags)
|
6
|
+
#
|
7
|
+
# W2TAGS is a shortcut of tags, macros, and it is very simple describer for HTML
|
8
|
+
# its not to become a replacement for inline tamplating engine, it best use for
|
9
|
+
# developement (sinatra / rails / merb) and the result is an "erb" file to be
|
10
|
+
# execute by erb or erubis (the fastest templating engine).
|
11
|
+
#
|
12
|
+
# It focus on how developer can code and generate dynamic content with
|
13
|
+
# DRY philosophy, easy to understand and in a very clean way.
|
14
|
+
#
|
15
|
+
# == Features
|
16
|
+
#
|
17
|
+
# * Mimics HAML syntax (inherit features define in HAML)
|
18
|
+
# * Extended syntax for Next Tag, Variable, Constanta
|
19
|
+
# * HOT file is patern for put in repetitif code and leter can be call it
|
20
|
+
# * HOT Variable interpolation, make it code really DRY
|
21
|
+
#
|
22
|
+
# == Using W2TAGS
|
23
|
+
#
|
24
|
+
# some of the guide are inside
|
25
|
+
# * README.rdoc
|
26
|
+
# * doc/W2TAGS.rdoc
|
27
|
+
# * doc/HAML.rdoc
|
28
|
+
# * doc/FAQ.rdoc
|
29
|
+
# * doc/HOT.rdoc
|
30
|
+
|
31
|
+
module W2Tags
|
32
|
+
Dir = File.dirname(__FILE__)
|
33
|
+
VERSION = File.read(Dir + '/../VERSION').strip unless defined?(VERSION)
|
34
|
+
|
35
|
+
#split string with aditional option escape charaters'\'
|
36
|
+
def self.splitter(data,deli=';')
|
37
|
+
tg_esc = data.split("\\"+deli)
|
38
|
+
if tg_esc.size > 1
|
39
|
+
tg_esc = tg_esc.collect {|x|x.split(deli)}
|
40
|
+
result = tg_esc.shift
|
41
|
+
while tg_esc != []
|
42
|
+
token = tg_esc[0]
|
43
|
+
result[-1,1] = result[-1,1][0] +';'+ token[0,1][0]
|
44
|
+
result = result + token[1,99]
|
45
|
+
tg_esc.shift
|
46
|
+
end
|
47
|
+
else
|
48
|
+
result = data.split(deli)
|
49
|
+
end
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
53
|
+
#hot files is a collection of w2tags function
|
54
|
+
#example of the function that will translate by this method
|
55
|
+
#
|
56
|
+
# >>body
|
57
|
+
# <body>
|
58
|
+
# <</
|
59
|
+
# </body>
|
60
|
+
#
|
61
|
+
#and example of use that function
|
62
|
+
# @body()
|
63
|
+
# @div!Hello Tags
|
64
|
+
# ./
|
65
|
+
#
|
66
|
+
#it will produce
|
67
|
+
# <body>
|
68
|
+
# <div>Hello Tags</div>
|
69
|
+
# </body>
|
70
|
+
def self.read_filehot(fhot)
|
71
|
+
hot_new = {}
|
72
|
+
hot = ("\n"+IO.read(fhot)).delete("\r").split(/\n\>\>/)
|
73
|
+
hot.shift
|
74
|
+
hot.each do |item|
|
75
|
+
item.gsub!(/\n([ \t]*)$/,'') #remove blank lines
|
76
|
+
ends = item.split(/\n\<\<\/[^\n]*\n/) #hots | ends
|
77
|
+
mems = ends[0].split(/\n\!~[^\n]*\n/) #hots | mems
|
78
|
+
khot = mems[0].split("\n") #key | hot
|
79
|
+
keys = khot.shift.rstrip #hots = mems[0].gsub(keys+"\n",'')
|
80
|
+
hots = khot.join("\n")
|
81
|
+
hot = [nil,nil]
|
82
|
+
hot[0]= proc do |this|
|
83
|
+
this.chg_mem_hot(mems[1]) if this!= nil
|
84
|
+
hots
|
85
|
+
end
|
86
|
+
if ends.size>1
|
87
|
+
hot[1] = [ends[1]]
|
88
|
+
# tend = splitter(ends[1])
|
89
|
+
# if tend.size==1
|
90
|
+
# hot[1] = [tend]
|
91
|
+
# else
|
92
|
+
# hot[1] = tend.collect {|x|"</#{x}>"}
|
93
|
+
# end
|
94
|
+
end
|
95
|
+
hot_new[keys] = hot
|
96
|
+
end
|
97
|
+
hot_new
|
98
|
+
end
|
99
|
+
end
|
100
|
+
require 'w2tags/parser'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
Scaffold with w2tags Generator
|
2
|
-
====
|
1
|
+
Scaffold with w2tags Generator
|
2
|
+
====
|
@@ -1,29 +1,29 @@
|
|
1
|
-
Description:
|
2
|
-
Scaffolds an entire resource, from model and migration to controller and
|
3
|
-
views, along with a full test suite. The resource is ready to use as a
|
4
|
-
starting point for your RESTful, resource-oriented application.
|
5
|
-
|
6
|
-
Pass the name of the model (in singular form), either CamelCased or
|
7
|
-
under_scored, as the first argument, and an optional list of attribute
|
8
|
-
pairs.
|
9
|
-
|
10
|
-
Attribute pairs are column_name:sql_type arguments specifying the
|
11
|
-
model's attributes. Timestamps are added by default, so you don't have to
|
12
|
-
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
13
|
-
|
14
|
-
You don't have to think up every attribute up front, but it helps to
|
15
|
-
sketch out a few so you can start working with the resource immediately.
|
16
|
-
|
17
|
-
For example, 'scaffold post title:string body:text published:boolean'
|
18
|
-
gives you a model with those three attributes, a controller that handles
|
19
|
-
the create/show/update/destroy, forms to create and edit your posts, and
|
20
|
-
an index that lists them all, as well as a map.resources :posts
|
21
|
-
declaration in config/routes.rb.
|
22
|
-
|
23
|
-
If you want to remove all the generated files, run
|
24
|
-
'script/destroy scaffold ModelName'.
|
25
|
-
|
26
|
-
Examples:
|
27
|
-
`./script/generate w2scaffold post`
|
28
|
-
`./script/generate w2scaffold post title:string body:text published:boolean`
|
29
|
-
`./script/generate w2scaffold purchase order_id:integer amount:decimal`
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire resource, from model and migration to controller and
|
3
|
+
views, along with a full test suite. The resource is ready to use as a
|
4
|
+
starting point for your RESTful, resource-oriented application.
|
5
|
+
|
6
|
+
Pass the name of the model (in singular form), either CamelCased or
|
7
|
+
under_scored, as the first argument, and an optional list of attribute
|
8
|
+
pairs.
|
9
|
+
|
10
|
+
Attribute pairs are column_name:sql_type arguments specifying the
|
11
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
12
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
13
|
+
|
14
|
+
You don't have to think up every attribute up front, but it helps to
|
15
|
+
sketch out a few so you can start working with the resource immediately.
|
16
|
+
|
17
|
+
For example, 'scaffold post title:string body:text published:boolean'
|
18
|
+
gives you a model with those three attributes, a controller that handles
|
19
|
+
the create/show/update/destroy, forms to create and edit your posts, and
|
20
|
+
an index that lists them all, as well as a map.resources :posts
|
21
|
+
declaration in config/routes.rb.
|
22
|
+
|
23
|
+
If you want to remove all the generated files, run
|
24
|
+
'script/destroy scaffold ModelName'.
|
25
|
+
|
26
|
+
Examples:
|
27
|
+
`./script/generate w2scaffold post`
|
28
|
+
`./script/generate w2scaffold post title:string body:text published:boolean`
|
29
|
+
`./script/generate w2scaffold purchase order_id:integer amount:decimal`
|