Permalink
Browse files

left these out when committed 0.2 version

  • Loading branch information...
Chris Goddard
Chris Goddard committed Mar 1, 2010
1 parent b771255 commit 2b24d1fb64d1562aabf46747e226a6a486797521
Showing with 15 additions and 7 deletions.
  1. +9 −2 README.rdoc
  2. +0 −1 lib/haml2erb.rb
  3. +1 −1 lib/haml2erb/erb_writer.rb
  4. +5 −3 lib/haml2erb/parser.rb
View
@@ -2,7 +2,7 @@
haml2erb is a tool for converting {Haml markup}[http://haml-lang.com/] to Erb markup.
-<b>Latest version:</b> 0.1.0
+<b>Latest version:</b> 0.2.0
* API documentation (coming soon)
* {Source code} [http://github.com/cgoddard/haml2erb/]
@@ -25,11 +25,18 @@ markup translated into erb.
Haml2Erb.convert('.foo')
# => "<div class='foo'>\n</div>\n"
+=== Not supported yet
+
+Parsing of tag internal string interpolations, such as:
+#my_div{ class: "box #{extra_classes}" }
+
+Coming soon though ...
+
== Licenses
==== haml2erb code and documentation (MIT license)
- Copyright (c) 2009 Chris Goddard
+ Copyright (c) 2010 Chris Goddard
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -2,7 +2,6 @@
require 'haml2erb/parser'
module Haml2Erb
-
def self.convert(text)
parser = Haml2Erb::HamlParser.new
writer = Haml2Erb::ErbWriter.new
@@ -14,7 +14,7 @@ def <<(line_options)
@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]
+ @processed << " class='#{[*line_options[:element_class]].join(' ')}'" 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
View
@@ -1,5 +1,7 @@
require 'haml2erb/lexer'
require 'haml2erb/tokens'
+require 'haml2erb/mixins/comerging'
+require 'mixology'
module Haml2Erb
class HamlParser
@@ -15,7 +17,7 @@ def parse(unprocessed, writer)
# process incoming text one line at a time
unprocessed.each_line do |line|
@line_number += 1
- options = { }
+ options = { }.mixin Haml2Erb::Mixins::CoMerging
@lexer.load_input(line)
# handle indent
@@ -26,7 +28,7 @@ def parse(unprocessed, writer)
# handle initial tag attributes
while(@lexer.peek(Haml2Erb::Tokens::InitialAttribute))
- options.merge!(@lexer.pop(Haml2Erb::Tokens::InitialAttribute).options)
+ options.comerge!(@lexer.pop(Haml2Erb::Tokens::InitialAttribute).options)
end
options[:element_type] = :div if((options[:element_id] || options[:element_class]) && !options[:element_type])
@@ -61,7 +63,7 @@ def parse(unprocessed, writer)
writer << options
end
rescue => error
- raise ParsingError, "Haml2Erb had trouble parsing line #{@line_number} with input '#{@lexer.input}' remaining: #{error.to_s}"
+ raise ParsingError, "Haml2Erb had trouble parsing line #{@line_number} with input '#{@lexer.input}' remaining: #{error.to_s}", error.backtrace
end
end
end

0 comments on commit 2b24d1f

Please sign in to comment.