Gem: haml

This commit is contained in:
2008-03-02 19:19:02 -03:00
parent c5cb69f277
commit 3f8c9f0ae6
107 changed files with 8275 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
%p
@foo =
= @foo
- @foo = 'value three'
%p
@foo =
= @foo

View File

@@ -0,0 +1,3 @@
.text_area_test_area
~ "<textarea>" + value + "</textarea>"
= "<textarea>BLAH\n</textarea>"

View File

@@ -0,0 +1,8 @@
%p
%h1 Hello!
= "lots of lines"
- raise "Oh no!"
%p
this is after the exception
%strong yes it is!
ho ho ho.

View File

@@ -0,0 +1,10 @@
!!!
%html
%head
%body
#content
= @content_for_layout
#yieldy
= yield :layout
#nosym
= yield

View File

@@ -0,0 +1,10 @@
= "not me!"
= "nor me!"
- puts "not even me!"
%p= "NO!"
%h1 Me!
#foo
%p#bar All
%br/
%p.baz This
Should render

View File

@@ -0,0 +1,53 @@
%style
:sass
p
:border
:style dotted
:width 10px
:color #ff00ff
h1
:font-weight normal
:test
This
Should
Not
Print
:redcloth
Foo
===
This is preformatted!
Look at that!
Wowie-zowie!
*boldilicious!*
:textile
h1. Yeah
_pretty much the same as above_
:plain
This
Is
Plain
Text
%strong right?
:erb
<% 10.times do |c| %>
<%= (c+97).chr %>
<% end %>
:markdown
* Foo
* Bar
* BAZ!
= "Text!"
:ruby
puts "Hello, World!"
puts "How are you doing today?"

View File

@@ -0,0 +1,63 @@
= h("&&&&&&&&&&&") # This is an ActionView Helper... should load
- foo = capture do # This ActionView Helper is designed for ERB, but should work with haml
%div
%p.title Title
%p.text
Woah this is really crazy
I mean wow,
man.
- 3.times do
= foo
%p foo
- tab_up
%p reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally loooooooooooooooooong
- tab_down
.woah
#funky
= capture_haml do
%div
%h1 Big!
%p Small
/ Invisible
= capture do
.dilly
%p foo
%h1 bar
= surround '(', ')' do
%strong parentheses!
= precede '*' do
%span.small Not really
click
= succeed '.' do
%a{:href=>"thing"} here
%p baz
- buffer.tabulation = 10
%p boom
- concat "foo\n"
- buffer.tabulation = 0
- def url_for(*stuff); stuff.join(' '); end
%p
= form_tag 'hello/world'
- form_tag 'heeheeaform' do
%div= submit_tag 'save'
- form_for :article, @article, :url => 'article_url' do |f|
Title:
= f.text_field :title
Body:
= f.text_field :body
= list_of({:google => 'http://www.google.com'}) do |name, link|
%a{ :href => link }= name
%p
- puts "foo"
%div
- puts "bar"
- puts "boom"
baz
- puts "boom, again"
- open :table do
- open :tr do
- open :td, {:class => 'cell'} do
- open :strong, "strong!"
- puts "data"
- open :td do
- puts "more_data"

View File

@@ -0,0 +1,11 @@
%div[@article]
%h1= @article.title
%div= @article.body
#id[@article] id
.class[@article] class
#id.class[@article] id class
%div{:class => "article full"}[@article]= "boo"
%div{'class' => "article full"}[@article]= "moo"
%div.articleFull[@article]= "foo"
%span[@not_a_real_variable_and_will_be_nil]
Boo

View File

@@ -0,0 +1,69 @@
!!! XML
!!! XML ISO-8859-1
!!! XML UtF-8 Foo bar
!!!
!!! 1.1
!!! 1.1 Strict
!!! Strict foo bar
!!! FRAMESET
%strong{:apos => "Foo's bar!"} Boo!
== Embedded? false!
== Embedded? #{true}!
- embedded = true
== Embedded? #{embedded}!
.render= render :inline => "%em= 'wow!'", :type => :haml
= "stuff followed by whitespace"
- if true
%strong block with whitespace
%p
\Escape
\- character
\%p foo
\yee\ha
/ Short comment
/ This is a really long comment look how long it is it should be on a line of its own don't you think?
/
This is a block comment
cool, huh?
%strong there can even be sub-tags!
= "Or script!"
-# Haml comment
-#
Nested Haml comment
- raise 'dead'
%p{ :class => "" } class attribute shouldn't appear!
/[if lte IE6] conditional comment!
/[if gte IE7]
%p Block conditional comment
%div
%h1 Cool, eh?
/[if gte IE5.2]
Woah a period.
= "test" |
"test" |
-# Hard tabs shouldn't throw errors.
- case :foo
- when :bar
%br Blah
- when :foo
%br
- case :foo
- when :bar
%meta{ :foo => 'blah'}
- when :foo
%meta{ :foo => 'bar'}
%img
%hr
%link
%script Inline content
%br
Nested content
%p.foo{:class => true ? 'bar' : 'baz'}[@article] Blah
%p.foo{:class => false ? 'bar' : ''}[@article] Blah
%p.qux{:class => 'quux'}[@article] Blump
== #{"Woah inner quotes"}
%p.dynamic_quote{:quotes => "single '", :dyn => 1 + 2}
%p.dynamic_atomic{:dyn => 1 + 2}/

View File

@@ -0,0 +1,12 @@
! Not a Doctype !
%ul
%li a
%li b
%li c
%li d
%li e
%li f
%li g
%li h
%li i

View File

@@ -0,0 +1,17 @@
!!!
%html
%head
%title Stop. haml time
#content
%h1 This is a title!
%p Lorem ipsum dolor sit amet, consectetur adipisicing elit
%p{:class => 'foo'} Cigarettes!
%h2 Man alive!
%ul.things
%li Slippers
%li Shoes
%li Bathrobe
%li Coffee
%pre
This is some text that's in a pre block!
Let's see what happens when it's rendered! What about now, since we're on a new line?

View File

@@ -0,0 +1 @@
= render :file => "#{name}.haml"

View File

@@ -0,0 +1,12 @@
%p
@foo =
= @foo
- @foo = 'value two'
%p
@foo =
= @foo
= render :file => "_partial.haml"
%p
@foo =
= @foo
- @foo = 'value one'

View File

@@ -0,0 +1,40 @@
%div
%h1 I can count!
- (1..20).each do |i|
= i
%h1 I know my ABCs!
%ul
- ('a'..'z').each do |i|
%li= i
%h1 I can catch errors!
- begin
- String.silly
- rescue NameError => e
= "Oh no! \"#{e}\" happened!"
%p
"false" is:
- if false
= "true"
- else
= "false"
- if true
- 5.times do |i|
- if i % 2 == 1
Odd!
- else
Even!
- else
= "This can't happen!"
- 13 |
.foo
%strong foobar
- 5.times |
do |
|a| |
%strong= a
.test
- "foo |
bar |
baz" |
%p boom

View File

@@ -0,0 +1,43 @@
!!!
%html{html_attrs}
%head
%title Hampton Catlin Is Totally Awesome
%meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
%body
/ You're In my house now!
- concat("foo\n")
.header
Yes, ladies and gentileman. He is just that egotistical.
Fantastic! This should be multi-line output
The question is if this would translate! Ahah!
= 1 + 9 + 8 + 2 #numbers should work and this should be ignored
#body= " Quotes should be loved! Just like people!"
- 120.times do |number|
- number
Wow.|
%p
= "Holy cow " + |
"multiline " + |
"tags! " + |
"A pipe (|) even!" |
= [1, 2, 3].collect { |n| "PipesIgnored|" }
= [1, 2, 3].collect { |n| |
n.to_s |
}.join("|") |
%div.silent
- foo = String.new
- foo << "this"
- foo << " shouldn't"
- foo << " evaluate"
= foo + " but now it should!"
-# Woah crap a comment!
-# That was a line that shouldn't close everything.
%ul.really.cool
- ('a'..'f').each do |a|
%li= a
#combo.of_divs_with_underscore= @should_eval = "with this text"
= [ 104, 101, 108, 108, 111 ].map do |byte|
- byte.chr
.footer
%strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works"

View File

@@ -0,0 +1,24 @@
%div.tags
%foo 1
%FOO 2
%fooBAR 3
%fooBar 4
%foo_bar 5
%foo-bar 6
%foo:bar 7
%foo.bar 8
%fooBAr_baz:boom_bar 9
%foo13 10
%foo2u 11
%div.classes
%p.foo.bar#baz#boom
.fooBar a
.foo-bar b
.foo_bar c
.FOOBAR d
.foo16 e
.123 f
.foo2u g
%div.broken
%foo<{ :a => :b }
.foo>{ :c => :d }

View File

@@ -0,0 +1,4 @@
!!!
%html
%head
%body

View File

@@ -0,0 +1,87 @@
#whitespace_test
= render :file => "_text_area.haml", :locals => { :value => "Oneline" }
= render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
~ render :file => "_text_area.haml", :locals => { :value => "Oneline" }
~ render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
#flattened~ render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
.hithere
~ "Foo bar"
~ "<pre>foo bar</pre>"
~ "<pre>foo\nbar</pre>"
%p~ "<pre>foo\nbar</pre>"
%p~ "foo\nbar"
.foo
~ 13
~ ['a', 'b', 'c'].map do |a|
- "<textarea>\n#{a}\n</textarea>"
#whitespace_test
= render :file => "_text_area.haml", :locals => { :value => "Oneline" }
= render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
= find_and_preserve render(:file => "_text_area.haml", :locals => { :value => "Oneline" })
= find_and_preserve render(:file => "_text_area.haml", :locals => { :value => "Two\nlines" })
#flattened= find_and_preserve render(:file => "_text_area.haml", :locals => { :value => "Two\nlines" })
.hithere
= find_and_preserve("Foo bar")
= find_and_preserve("<pre>foo bar</pre>")
= find_and_preserve("<pre>foo\nbar</pre>")
%p= find_and_preserve("<pre>foo\nbar</pre>")
%p= find_and_preserve("foo\nbar")
%pre
:preserve
___
,o88888
,o8888888'
,:o:o:oooo. ,8O88Pd8888"
,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
, ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
, ..:.::o:ooOoOO8O888O8O,COCOO"
, . ..:.::o:ooOoOOOO8OOOOCOCO"
. ..:.::o:ooOoOoOO8O8OCCCC"o
. ..:.::o:ooooOoCoCCC"o:o
. ..:.::o:o:,cooooCo"oo:o:
` . . ..:.:cocoooo"'o:o:::'
.` . ..::ccccoc"'o:o:o:::'
:.:. ,c:cccc"':.:.:.:.:.'
..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
...:.'.:.::::"' . . . . .'
.. . ....:."' ` . . . ''
. . . ...."'
.. . ."' -hrr-
.
It's a planet!
%strong This shouldn't be bold!
%strong This should!
%textarea
:preserve
___ ___ ___ ___
/\__\ /\ \ /\__\ /\__\
/:/ / /::\ \ /::| | /:/ /
/:/__/ /:/\:\ \ /:|:| | /:/ /
/::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ /
/:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/
\/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \
\::/ / \::/ / /:/ / \:\ \
/:/ / /:/ / /:/ / \:\ \
/:/ / /:/ / /:/ / \:\__\
\/__/ \/__/ \/__/ \/__/
Many
thanks
to
http://www.network-science.de/ascii/
%strong indeed!
.foo
= find_and_preserve(13)
%pre
:preserve
__ ______ __ ______
.----.| |--.|__ |.----.| |--..--------.| __ |
| __|| ||__ || __|| < | || __ |
|____||__|__||______||____||__|__||__|__|__||______|
%pre
:preserve
foo
bar