Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit f469253b046760b3c3b8f14980fd6f85133685c6 Chris Goddard committed Nov 25, 2009
0 README
No changes.
@@ -0,0 +1 @@
+require 'haml2erb'
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 63
+/svn/!svn/ver/4456/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib
+END
+haml2erb.rb
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/svn/!svn/ver/4267/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib/haml2erb.rb
+END
@@ -0,0 +1,65 @@
+9
+
+dir
+4514
+https://dev/svn/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib
+https://dev/svn
+
+
+
+2009-11-03T22:04:25.050143Z
+4456
+cgoddard
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+b9f8662a-f611-0410-925b-ccc9c76f1e89
+
+haml2erb
+dir
+
+haml2erb.rb
+file
+
+
+
+
+2009-10-23T18:50:50.000000Z
+7821112388140815c7a734f04c1d63a8
+2009-09-22T17:06:13.227512Z
+4267
+cgoddard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+243
+
@@ -0,0 +1 @@
+9
@@ -0,0 +1,12 @@
+require 'haml2erb/erb_writer'
+require 'haml2erb/parser'
+
+module Haml2Erb
+
+ def self.convert(text)
+ parser = Haml2Erb::HamlParser.new
+ writer = Haml2Erb::ErbWriter.new
+ parser.parse(text, writer)
+ writer.output_to_string
+ end
+end
@@ -0,0 +1,12 @@
+require 'haml2erb/erb_writer'
+require 'haml2erb/parser'
+
+module Haml2Erb
+
+ def self.convert(text)
+ parser = Haml2Erb::HamlParser.new
+ writer = Haml2Erb::ErbWriter.new
+ parser.parse(text, writer)
+ writer.output_to_string
+ end
+end
@@ -0,0 +1,29 @@
+K 25
+svn:wc:ra_dav:version-url
+V 72
+/svn/!svn/ver/4456/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib/haml2erb
+END
+lexer.rb
+K 25
+svn:wc:ra_dav:version-url
+V 81
+/svn/!svn/ver/4267/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib/haml2erb/lexer.rb
+END
+tokens.rb
+K 25
+svn:wc:ra_dav:version-url
+V 82
+/svn/!svn/ver/4456/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib/haml2erb/tokens.rb
+END
+erb_writer.rb
+K 25
+svn:wc:ra_dav:version-url
+V 86
+/svn/!svn/ver/4267/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib/haml2erb/erb_writer.rb
+END
+parser.rb
+K 25
+svn:wc:ra_dav:version-url
+V 82
+/svn/!svn/ver/4300/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib/haml2erb/parser.rb
+END
@@ -0,0 +1,164 @@
+9
+
+dir
+4514
+https://dev/svn/tolkin_RoR/trunk/vendor/plugins/haml2erb/lib/haml2erb
+https://dev/svn
+
+
+
+2009-11-03T22:04:25.050143Z
+4456
+cgoddard
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+b9f8662a-f611-0410-925b-ccc9c76f1e89
+
+lexer.rb
+file
+
+
+
+
+2009-10-23T18:50:50.000000Z
+02acd53794204a20afc136c3e518b5fa
+2009-09-22T17:06:13.227512Z
+4267
+cgoddard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+523
+
+tokens.rb
+file
+
+
+
+
+2009-11-03T22:00:55.000000Z
+8c11e886b52c130dbc57a406c90f6f42
+2009-11-03T22:04:25.050143Z
+4456
+cgoddard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3126
+
+erb_writer.rb
+file
+
+
+
+
+2009-10-23T18:50:50.000000Z
+41b0614e28f8363607e4c87856c87a5e
+2009-09-22T17:06:13.227512Z
+4267
+cgoddard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1727
+
+parser.rb
+file
+
+
+
+
+2009-10-23T18:50:50.000000Z
+003d6b9080d7d772447394e9f3793508
+2009-10-01T15:11:05.537506Z
+4300
+cgoddard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2598
+
@@ -0,0 +1 @@
+9
@@ -0,0 +1,51 @@
+module Haml2Erb
+ class ErbWriter
+
+ def initialize
+ @processed = ''
+ @tag_stack = [ ]
+ end
+
+ def <<(line_options)
+
+ close_tags(line_options[:indent])
+ @tag_stack.push(line_options[:element_type]) if line_options[:element_type]
+
+ @processed << (" " * line_options[:indent]) if line_options[:indent]
+ @processed << "<#{line_options[:element_type].to_s}" if line_options[:element_type]
+ @processed << " id='#{line_options[:element_id].to_s}'" if line_options[:element_id]
+ @processed << " class='#{line_options[:element_class].to_s}'" if line_options[:element_class]
+ line_options[:element_attributes] && line_options[:element_attributes].keys.each do |attribute_key|
+ @processed << " #{attribute_key}='#{line_options[:element_attributes][attribute_key]}'"
+ end
+ @processed << ">" if line_options[:element_type]
+
+ case(line_options[:content_type])
+ when :text
+ @processed << (line_options[:contents] || "")
+ when :ruby
+ @processed << ("<%= " + line_options[:contents] + " %>")
+ when :mixed
+ @processed << ('<%= "' + line_options[:contents] + '" %>')
+ end
+
+ close_tags(line_options[:indent], :separate_line => false) if line_options[:contents]
+ @processed << "\n"
+ end
+
+ def output_to_string
+ close_tags(0)
+ @processed
+ end
+
+ private
+
+ def close_tags(current_indent, options = { :separate_line => true })
+ while(@tag_stack.size > current_indent)
+ @processed << (" " * (@tag_stack.size - 1)) if options[:separate_line] == true
+ @processed << "</#{@tag_stack.pop.to_s}>"
+ @processed << "\n" if options[:separate_line] == true
+ end
+ end
+ end
+end
@@ -0,0 +1,28 @@
+require 'haml2erb/tokens'
+
+module Haml2Erb
+ class HamlLexer
+
+ attr_reader :input
+
+ def load_input(text)
+ @input = text
+ end
+
+ def peek(klass)
+ #puts "peek #{klass} #{@input}"
+ klass.match(@input)
+ end
+
+ def pop(klass)
+ #puts "pop #{klass} #{@input}"
+ token = klass.match(@input)
+ @input.gsub!(/^#{Regexp.escape(token.matched)}/, '') # removed matched portion from the string
+ token
+ end
+
+ def end_input?
+ @input.strip.empty? ? true : false
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit f469253

Please sign in to comment.