Giter Site home page Giter Site logo

haml's Introduction

Haml

Gem Version test Code Climate Inline docs

Haml is a templating engine for HTML. It's designed to make it both easier and more pleasant to write HTML documents, by eliminating redundancy, reflecting the underlying structure that the document represents, and providing an elegant syntax that's both powerful and easy to understand.

Basic Usage

Haml can be used from the command line or as part of a Ruby web framework. The first step is to install the gem:

gem install haml

After you write some Haml, you can run

haml render document.haml

to compile it to HTML. For more information on these commands, check out

haml --help

To use Haml programmatically, check out the YARD documentation.

Using Haml with Rails

To use Haml with Rails, simply add Haml to your Gemfile and run bundle.

gem 'haml'

If you'd like to replace Rails's ERB-based generators with Haml, add haml-rails to your Gemfile as well.

Formatting

The most basic element of Haml is a shorthand for creating HTML:

%tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents

No end-tag is needed; Haml handles that automatically. If you prefer HTML-style attributes, you can also use:

%tagname(attr1='value1' attr2='value2') Contents

Adding class and id attributes is even easier. Haml uses the same syntax as the CSS that styles the document:

%tagname#id.class

In fact, when you're using the <div> tag, it becomes even easier. Because <div> is such a common element, a tag without a name defaults to a div. So

#foo Hello!

becomes

<div id='foo'>Hello!</div>

Haml uses indentation to bring the individual elements to represent the HTML structure. A tag's children are indented beneath than the parent tag. Again, a closing tag is automatically added. For example:

%ul
  %li Salt
  %li Pepper

becomes:

<ul>
  <li>Salt</li>
  <li>Pepper</li>
</ul>

You can also put plain text as a child of an element:

%p
  Hello,
  World!

It's also possible to embed Ruby code into Haml documents. An equals sign, =, will output the result of the code. A hyphen, -, will run the code but not output the result. You can even use control statements like if and while:

%p
  Date/Time:
  - now = DateTime.now
  %strong= now
  - if now > DateTime.parse("December 31, 2006")
    = "Happy new " + "year!"

Haml provides far more tools than those presented here. Check out the reference documentation for full details.

Indentation

Haml's indentation can be made up of one or more tabs or spaces. However, indentation must be consistent within a given document. Hard tabs and spaces can't be mixed, and the same number of tabs or spaces must be used throughout.

Contributing

Contributions are welcomed, but before you get started please read the guidelines.

After forking and then cloning the repo locally, install Bundler and then use it to install the development gem dependencies:

gem install bundler
bundle install

Once this is complete, you should be able to run the test suite:

rake

At this point rake should run without error or warning and you are ready to start working on your patch!

Note that you can also run just one test out of the test suite if you're working on a specific area:

ruby -Itest test/helper_test.rb -n test_buffer_access

Haml currently supports Ruby 2.0.0 and higher, so please make sure your changes run on 2.0+.

Team

Current Maintainers

Alumni

Haml was created by Hampton Catlin, the author of the original implementation. Hampton is no longer involved in day-to-day coding, but still consults on language issues.

Natalie Weizenbaum was for many years the primary developer and architect of the "modern" Ruby implementation of Haml.

Norman Clarke was the primary maintainer of Haml from 2012 to 2016.

License

Some of Natalie's work on Haml was supported by Unspace Interactive.

Beyond that, the implementation is licensed under the MIT License.

Copyright (c) 2006-2019 Hampton Catlin, Natalie Weizenbaum and the Haml team

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

haml's People

Contributors

aliismayilov avatar amatsuda avatar apotonick avatar cheald avatar chriseppstein avatar creasty avatar cristibalan avatar dillonwelch avatar hamptonmakes avatar indirect avatar jaredbeck avatar jdelstrother avatar jonallured avatar josh avatar k0kubun avatar kamal avatar lsylvester avatar mattwildig avatar mislav avatar mmircea16 avatar nex3 avatar norman avatar petergoldstein avatar robindaugherty avatar spohlenz avatar technomancy avatar teeparham avatar thedarkone avatar tmm1 avatar wjordan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

haml's Issues

Should be able to set encoding (ruby1.9)

HAML template files should be able to set the encoding for the file on the first line, similar to normal ruby. (or at least have some way of specifying the encoding per file.)

 -# encoding: utf-8
 %p
   Éat thís!

Compress color output

Colors printed by SassScript when the output format is :compressed should be printed in the smallest possible format. This means the shortest of "#nnnnnn", "#nnn", and the HTML4 color name, depending on what's available.

The Rails XSS protection doesn't work with Rails 2.3.5

Plugins are loaded after gems, so when haml (a gem) checks ActionView::Base.xss_safe?, it returns false (the rails 2.3.5 default value). After this, the rails_xss plugin is loaded and it modifies ActionView::Base.xss_safe? to return true, but it's too late.

Integrate Chris Eppstein's compass-colors Sass extensions

See chriseppstein/compass-colors. Only the Sass extensions (and corresponding HSL code) should be integrated - the color themes should be left there.

Most of the work for this will probably be in testing and documentation. The compass-colors tests aren't as complete as I'd like... it would be good to have tests for each of the new Sass functions. And the new functions should be documented in the YARD style of the rest of the Sass functions.

%a(href="#") raises an error

Guys, I wrote the following markup:
%a(href="#") All

But it is raising an error. I could fix that writing:
%a(href="#") All

I had to escape the "#" character. I think that it is an error and maybe it's about a bad parsing in the interpolation feature. Maybe the parser is thinking that I am trying to interpolate something just because i used the "#" character. You could interpolate something just if it is inside a #{...}, and not when you find a #.

What do you think?

SASS badly indent support in mixins

When there's empty line within mixin sass generates output code outside mixin instead of include it. Gem version haml-edge-2.1.33

Example:

=example_mixin
  :width 200px
  :height 200px

  .example_class
    :float left

Output:

.example_class {
  float: left; }

#example_id {
  width: 200px;
  height: 200px; }

Instead of:

#example_id {
  width: 200px;
  height: 200px; }

#example_id .example_class {
  float: left; }

:javascript filter breaks #{local} variables

on haml 2.0.9

```
require ‘haml/engine’

template_broken = ’
:javascript
– [1, 2, 3, 4].each do |item|
= “Hey #{item}”

puts Haml::Engine.new(template_broken).to_html
```

causes

```
(haml):3:in `to_html’: undefined local variable or method `item’ for # (NameError)
from c:/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/engine.rb:149:in `to_html’
from c:/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/engine.rb:149:in `instance_eval’
from c:/ruby/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/engine.rb:149:in `to_html’
from haml.rb:9
```

however, this works just fine. notice that I replaced :javascript filter with regular %script tag.

```
require ‘haml/engine’

template_broken = ’
%script
– [1, 2, 3, 4].each do |item|
= “Hey #{item}”

puts Haml::Engine.new(template_broken).to_html
```

Extraneous spaces in tags with elements with an apostrophe in an attribute

Compare the following two snippets of code.

%one
  %two
    %three
      %four{:attr => ""}

This renders as:






This seems to be correct. The second snippet of code only adds a single apostrophe to the attribute:

%one
  %two
    %three
      %four{:attr => "'"}

However, this renders as:






There is extraneous spacing inside the 'four' tag, which seems to be equal to the indentation amount of the 'four' tag. Experimentation shows that the deeper into the nesting 'four' is, the more spaces crop up. This issue does not appear when using the parenthesized list () instead of the Ruby hash {}. I am using the Powerful Penny release with Ruby on Rails.

Adjacent multi-line nodes are parsed incorrectly.

%p This is a test of the multi-line | 
   system.  |
%p This should be part of a separate p |
   element. |

outputs:

This is a test of the multi-line system.
%p This should be part of a separate p element.

.

While
%p This is a test of the multi-line |
system. |
%p This should be part of a separate p element.

works correctly

css2sass does not preserve source order

Assume the following source CSS:

div .warning {
  color: #d21a19; }
span .debug { 
  cursor: crosshair;}
div .debug {
  cursor: default; }

css2sass 2.1.0 results in:

div
  .warning
    :color #d21a19
  .debug
    :cursor default
span .debug
  :cursor crosshair

Of course, this results in CSS like so:

div .warning {
  color: #d21a19; }
div .debug {
  cursor: default; }
span .debug {
  cursor: crosshair; }

Since the selectors have the same specificity, order is important, and css2sass seems to prefer to nesting level over origin order. The sass produced should have been:

div
  .warning
    :color #d21a19
span 
  .debug
    :cursor crosshair
div
  .debug
    :cursor default

Don't output unnecessary closing tags with :ugly

When running with :ugly => true and :format => :html4 or :format => :html5, don't output closing tags that aren't required. A list of closing tags that aren't required is given here. Note that sometimes these closing tags should be printed. In particular, if the closing tag isn't followed immediately by an opening or tag - one generated by Haml - output it. For example, in all of the following situations:

%p foo
<strong>bar</strong>
%p foo
= "<strong>bar</strong>"
%p foo
:plain
  <strong>bar</strong> 

the closing tag should be preserved.

Warning: it's likely to be very difficult to figure out exactly when you may and may not output a closing tag.

Comments within @media declarations don't work

This Sass file

// Working comment
@media screen, projection
  // Not working comment
  body
    color: green

causes this error:

/*
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+

Backtrace:
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/tree/directive_node.rb:39:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/tree/directive_node.rb:21:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/tree/directive_node.rb:21:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/tree/node.rb:36:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/tree/node.rb:32:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/tree/node.rb:32:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/engine.rb:104:in `render'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/plugin.rb:75:in `update_stylesheet'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/plugin.rb:60:in `update_stylesheets'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/plugin.rb:55:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/plugin.rb:55:in `update_stylesheets'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/plugin.rb:53:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/plugin.rb:53:in `update_stylesheets'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/lib/sass/plugin/rails.rb:16:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/base.rb:391:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/base.rb:386:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/routing/route_set.rb:433:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:88:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:111:in `_call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:82:in `initialize'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:29:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:29:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:9:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:28:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/head.rb:9:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb:24:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/params_parser.rb:15:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/rewindable_input.rb:25:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:93:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/reloader.rb:9:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/failsafe.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/lock.rb:11:in `synchronize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:106:in `call'
/Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/rails/rack/static.rb:31:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb:46:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb:40:in `each'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb:40:in `call'
/Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/rails/rack/log_tailer.rb:17:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/content_length.rb:13:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/chunked.rb:15:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb:61:in `process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb:34:in `run'
/Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:111
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
./script/server:3
*/

If the "Not working comment" is removed everything works fine and as expected.

Comment Node value not picking up empty new lines

If I have a comment node that looks like:

/**
  This the first line.  There is an empty line below me.

  This is the third line

And I do call .value on that CommentNode, I get this:

"This the first line. There is an empty line below me.\nThis is the third line"

instead of

"This the first line. There is an empty line below me.\n\nThis is the third line"

"+"-issue

Breaks:

+ .description
  :color #000

Works:

+
  .description
    :color #000

But this works:

> .description
  :color #000

and

>
  .description
    :color #000

Should maybe be more consistent?

Implement a :no_interpolation filter.

This filter should be the same as :plain, except that it should interpret #{} within it as literal text, not interpolation. For example,

:no_interpolation
  foo #{bar} baz

should compile to

foo #{bar} baz

Add a :css filter

This should behave just like the :javascript filter, except with <style> tags instead of <script> tags.

Very obscure exception caused by special case line in SASS

This is something that got introduced in 2.1.0, because I didn't have this issue before:

SASS:

:color transparent
//:image url(../images/menu_gray_arrow.png)
:image url(../images/navigation/menu_arrows_supplier.png)

Outputs in browser:

TypeError: can't convert nil into String

...and in the containing CSS:

/*
TypeError: can't convert nil into String

Backtrace:
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/attr_node.rb:38:in `<<'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/attr_node.rb:38:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/attr_node.rb:37:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/attr_node.rb:37:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:77:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:77:in `map'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:77:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:88:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:88:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:88:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:88:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/rule_node.rb:87:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/node.rb:36:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/node.rb:32:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/tree/node.rb:32:in `to_s'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/engine.rb:104:in `render'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/plugin.rb:75:in `update_stylesheet'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/plugin.rb:60:in `update_stylesheets'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/plugin.rb:55:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/plugin.rb:55:in `update_stylesheets'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/plugin.rb:53:in `each'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/plugin.rb:53:in `update_stylesheets'
/Library/Ruby/Gems/1.8/gems/haml-2.1.0/rails/../lib/sass/plugin/rails.rb:16:in `process'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:433:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:88:in `dispatch_without_newrelic'
/Users/jonas/.gem/ruby/1.8/gems/newrelic_rpm-2.8.9/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb:44:in `dispatch'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:111:in `_call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:82:in `initialize'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/rewindable_input.rb:25:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb:122:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/Users/jonas/Development/m2m/jobbix/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
/Users/jonas/Development/m2m/jobbix/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/reloader.rb:9:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/failsafe.rb:11:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchronize'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/railties/lib/rails/rack/static.rb:31:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
/Users/jonas/Development/m2m/jobbix/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/chunked.rb:15:in `call'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:61:in `process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Users/jonas/.gem/ruby/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:34:in `run'
/Users/jonas/Development/m2m/jobbix/vendor/rails/railties/lib/commands/server.rb:111
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
*/
body:before {
  white-space: pre;
  font-family: monospace;
  content: "TypeError: can't convert nil into String"; }

Works:

SASS:

:color transparent
:image url(../images/navigation/menu_arrows_supplier.png)

I don't see why this line is any different than any other commented lines, i.e. leading @//@?

Support rgba and hsla in script contexts

Color objects need an alpha layer and we need to build corresponding support for rgba() and hsla() functions.

Color objects that have 100% opacity shouldn't output as rgba(), of course.

Universal Interpolation... lines should be allowed to start with #

With the universal interpolation implementation, I very often like to start the line with #{} in order to add stuff to the end.

For example

```
.contact_info
#{person.name}’s Address
Something else…
```

This currently fails.

Would be very nice if the precompiler could recognize #{ as a starting character and switch the line mode to normal interpolation (“==” style).

Very, very specific strangeness. Having to do with strings containing "-end" in a HAML template.

Not sure if this is an issue with HAML code or with the Rails code.

Rails: 2.3.4
Haml: 2.2.4

A gist containing more information

The evil line from my template:
- form_for @user, :html => {:id => 'reset-password-end-form', :method => :put}, :url => password_reset_path do |f|

The exact errors reported were:
/home/kojul/railsigti/app/views/password_resets/edit.haml:22: syntax error, unexpected kENSURE, expecting kEND
/home/kojul/railsigti/app/views/password_resets/edit.haml:24: syntax error, unexpected $end, expecting kEND

Note the error messages... my template is only 20 lines, so this occurs after some of it has been processed.

I knew I didn't mis-indent anything, so I went looking around and found nothing on the issue.
Figured it out though.

Look at the id tag declaration... there's a "-end" in it. Changing it to "reset-passwordend-form" worked as did anything that didn't have specifically an "-end" in it.
It doesn't matter if it's the id tag either... it could be any tag and it just requires a "-end" in it to mess everything up.

As I said at the top, I'm not sure if this is an issue with the form_for helper or with something within the HAML code itself.

Implement filter composition

Allow multiple filters to be composed in Haml - first apply the rightmost one, then work your way left. For example,

:preserve:escaped
  <foo>
    <bar />
  </foo>

should produce

&lt;foo&gt;&#x000A;  &lt;bar /&gt;&#x000A;&lt;/foo&gt;

Allow variable indentation under certain circumstances

Currently, Sass insists that all indentation in a file be completely consistent. However, this means that it's not possible to get rid of a line without re-indenting everything beneath it, which is annoying when debugging code.

We want to allow variable indentation as long as it's unambiguous. For example, the following:

foo
  bar
      baz
        bang: bop
      boom: bip

should be the same as

foo
  bar
    baz
      bang: bop
    boom: bip

However, wherever we currently would raise an error, a warning should be printed.

Ambiguous cases should still be marked as erroneous. For example, the following

foo
    up: four spaces
  down: two spaces

should raise an error on the "down: two spaces" line.

This is conceptually the same as issue #28, but since Sass and Haml don't share parser code, they're listed separately.

Optionally inline .css

How about an config variable to define whether .css should be
@import'd or inlined? Or a way of indicating, in sass, whether an @import on a .css should be inlined rather than becoming a CSS @import?

Add support for encoding comments

At the beginning of the file, // encoding: name should have an effect as close as possible to that of Ruby's # encoding: name declarations.

Note that this is currently not applicable to Haml because Haml templates are usually loaded externally to Haml. See #38.

Closing metatags

If you write a similar construction:

-# Metatags
  -# Charset
%meta{:charset => 'utf-8'}
  -# Keywords
%meta{:name => 'keyword', :content => 'words'}

get this html

<meta charset="utf-8"></meta>
<meta name="keywords" content="words"></meta>

Meta should not have a closing tag

Sass errors should list their mixin backtrace.

For example,

=box-shadow(!value)
  -moz-box-shadow= !value
  -webkit-box-shadow= !value

+box-shadow(0 1px 3px rgba(0, 0, 0, 0.5))

should list both line 2 and line 5 in the backtrace. This should integrate with the existing import backtrace.

HTML escaping and string interpolation

I'm using haml 2.2.6, with the option html_escape activated.

I'm expecting that the two following lines are similar:

You &amp; me
You &amp; #{'me'}

But it's not the case. For the second line, the & is escaped, so the result is:

You &amp;amp; me

The documentation seems to match my expectation (only the string inperpolation should be escaped), but maybe, it's the normal behaviour. In that case, can I suggest to make it clear in the doc?

SASS Rails plugin broken due to RAILS_ROOT behaviour

Haml breaks current edge rails with error;
undefined method `first' for #Pathname:/public/stylesheets/sass

This can be fixed by changing all the paths in sass/plugin/rails.rb from RAILS_ROOT + '/public/stylesheets/sass' to "#{RAILS_ROOT}/public/stylesheets/sass" or even "#{Rails.root}/public/stylesheets/sass" since RAILS_ROOT is getting deprecated.

Pre tag doesn't preserve properly

The Haml reference says "Literal textarea and pre tags automatically preserve their content." by converting newlines "to the XHTML whitespace escape code, ". However, during some experiments of mine, this doesn't seem correct.

%outer
  %pre
    12345
    12345

The above Haml outputs as:

<outer>
  <pre>12345
  12345</pre>
</outer>

(note: it appears Markdown isn't liking the pre tag up there. Would appreciate learning how to fix that.)

This is quite incorrect, both per the reference and per the display of the above code. The second line suffers from extra visible whitespace to the left.

This also applies to the textarea element, and likely whatever other elements Haml deems to be whitespace-sensitive. I am using the Poweful Penny release with Ruby on Rails.

Mustache-alike generation.

Raising an issue to open discussion. I don't know either Haml or Mustache codebase well enough to start work on this straight away.

Chris Wanstrath (aka defunkt) has just released a great template engine 'Mustache' based on Google's CTemplate.

As a templating solution Mustache is great, but I don't think anybody can deny the cleanness and readability of HAML code.

I don't think it would be too difficult to modify HAML to support Mustache-like generation. This could even be an option on HAML which could be turned on an off.

I'm thinking something like:

a) no ruby code evalution, so (-, =) no longer evaluate.

b) new syntax {{#boolean}}, {{helper}}, {{{non_interpreted_helper}}} can be used anywhere in the code(ie as nodes and inside text nodes) and will be evaluated as expected.

c) integration into rails could be very simple. All template logic now goes into the helpers files.

Haml doesn't work properly with encoding under Passenger and Ruby 1.9.1

Hi,
I’m getting very strange issue under above configuration. [The similar issue](http://code.google.com/p/phusion-passenger/issues/detail?id=233) was reported on Passenger’s issue tracker but it was selected as invalid (I don’t know why).

I can’t locate where the issue is :(

ArgumentError in Home#index

Showing app/views/home/index.html.haml where line # raised:

invalid byte sequence in US-ASCII

Extracted source (around line #):

RAILS_ROOT: /mnt/hgfs/test
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.9.1/gems/haml-2.0.9/lib/haml/engine.rb:88:in `initialize'
/usr/local/lib/ruby/gems/1.9.1/gems/haml-2.0.9/lib/haml/template/plugin.rb:21:in `new'
/usr/local/lib/ruby/gems/1.9.1/gems/haml-2.0.9/lib/haml/template/plugin.rb:21:in `compile'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_view/template_handler.rb:11:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_view/renderable.rb:19:in `compiled_source'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_view/renderable.rb:70:in `compile!'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_view/renderable.rb:61:in `compile'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_view/renderable.rb:28:in `render'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_view/template.rb:194:in `render_template'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_view/base.rb:260:in `render'
/usr/local/lib/ruby/gems/1.9.1/gems/haml-2.0.9/lib/haml/helpers/action_view_mods.rb:14:in `render_with_haml'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:1241:in `render_for_file'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:937:in `render'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/benchmarking.rb:51:in `block in render_with_benchmark'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/usr/local/lib/ruby/1.9.1/benchmark.rb:308:in `realtime'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/benchmarking.rb:51:in `render_with_benchmark'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:1317:in `default_render'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:1323:in `perform_action'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/filters.rb:617:in `call_filters'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/usr/local/lib/ruby/1.9.1/benchmark.rb:308:in `realtime'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/flash.rb:141:in `perform_action_with_flash'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:523:in `process'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/filters.rb:606:in `process_with_filters'
/usr/local/lib/ruby/gems/1.9.1/gems/haml-2.0.9/lib/sass/plugin/rails.rb:19:in `process'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:391:in `process'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/base.rb:386:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.2/lib/action_controller/routing/route_set.rb:433:in `call'

Every file has utf-8 encoding.

When I run this website under the webrick it works fine.

Converting HTML to Haml doesn't work from TextMate due to problem in version.rb

I've submitted a pull request, but I'm opening this because my work mates also have the same problem and so it may be helpful to have more info on it out there.

My patch: http://github.com/kjvarga/haml/commit/5ef9b00176d97d9030200b4410f65087552067ae

When converting text in TextMate to Haml, you get an exception from vendor.rb (30) about not being able to find the VERSION file:

haml/version.rb:30:in `read': No such file or directory

The reason is because FILE as used in lib.rb in the scope() method is reported as:

/Users/karl/.gem/ruby/1.8/gems/haml-2.2.5/lib/haml/../haml.rb

Which is a relative path, so the File.dirname() calls don't end up at the Haml gem root as they should. I've created a simple patch to call File.expand_path(FILE) to make it absolute first.

Regards,
Karl

Support block-style CSS comments

Something like the following should work:

/**
 * Stuff
 * More stuff
 */

This is something to think about when implementing CSS-style syntax.

Allow variable indentation under certain circumstances

Currently, Haml insists that all indentation in a file be completely consistent. However, this means that it's not possible to get rid of a line without re-indenting everything beneath it, which is annoying when debugging code.

We want to allow variable indentation as long as it's unambiguous. For example, the following:

%foo
  %bar
      %baz
        bang
      boom

should be the same as

%foo
  %bar
    %baz
      bang
    boom

However, wherever we currently would raise an error, a warning should be printed.

Ambiguous cases should still be marked as erroneous. For example, the following

%foo
    up four spaces
  down two spaces

should raise an error on the "down two spaces" line.

This is conceptually the same as issue #29, but since Sass and Haml don't share parser code, they're listed separately.

HAML 2.1.x + Rails Edge => undefined method `filename' for #<ActionView::Template:0x3be5854>

Log:

Processing ApplicationController# (for ::1 at 2009-06-02 20:03:17) [GET]
Parameters: {"action"=>"index", "controller"=>"home"}

ActionView::TemplateError (undefined method `filename' for #ActionView::Template:0x3be5854) in /Users/jonas/Development/jobbix/app/views/home/index.html.haml:

haml (2.1.0) [v] lib/haml/template/plugin.rb:15:in `compile'
haml (2.1.0) [v] lib/sass/plugin/rails.rb:19:in `process'
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/opt/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rip cannot require HAML

Run rip install git://github.com/nex3/haml.git.

Now, try and require Haml. It fails as the Version class tries to look for the VERSION file in the root directory of the Haml package. Uh oh. Rip doesn't keep anything around other than the lib directory of the gem so there is no VERSION file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.