Skip to content

Commit

Permalink
left these out when committed 0.2 version
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Goddard committed Mar 1, 2010
1 parent b771255 commit 2b24d1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
11 changes: 9 additions & 2 deletions README.rdoc
Expand Up @@ -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/]
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/haml2erb.rb
Expand Up @@ -2,7 +2,6 @@
require 'haml2erb/parser'

module Haml2Erb

def self.convert(text)
parser = Haml2Erb::HamlParser.new
writer = Haml2Erb::ErbWriter.new
Expand Down
2 changes: 1 addition & 1 deletion lib/haml2erb/erb_writer.rb
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/haml2erb/parser.rb
@@ -1,5 +1,7 @@
require 'haml2erb/lexer'
require 'haml2erb/tokens'
require 'haml2erb/mixins/comerging'
require 'mixology'

module Haml2Erb
class HamlParser
Expand All @@ -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
Expand All @@ -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])

Expand Down Expand Up @@ -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.