Skip to content

Commit

Permalink
chapter 4 of the DRYML manual
Browse files Browse the repository at this point in the history
  • Loading branch information
al2o3cr committed Jan 5, 2012
1 parent 51d269d commit 7669361
Showing 1 changed file with 120 additions and 0 deletions.
120 changes: 120 additions & 0 deletions dryml/features/cookbook/04_tag_attributes.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
Feature: Tag attributes

Scenario: A tag with one attribute
Given a file named "example_taglib.dryml" with:
"""
<def tag="help-link" attrs="file">
<a class="help" href="/help/#{file}.html" param="default"/>
</def>
"""
And a file named "example.dryml" with:
"""
<help-link file="intro">Introductory Help</help-link>
"""
When I include the taglib "example_taglib"
And I render "example.dryml"
Then the output DOM should be:
"""
<a class="help" href="/help/intro.html">Introductory Help</a>
"""

Scenario: A tag with a boolean attribute
Given a file named "example_taglib.dryml" with:
"""
<def tag="help-link" attrs="file, new-window">
<a class="help" href="/help/#{file}.html" target="#{new_window ? '_blank' : '_self' }" param="default"/>
</def>
"""
And a file named "example.dryml" with:
"""
<help-link file="intro" new-window="&true">Introductory Help In A New Window</help-link>
<help-link file="intro" new-window="&false">Introductory Help</help-link>
"""
When I include the taglib "example_taglib"
And I render "example.dryml"
Then the output DOM should be:
"""
<a class="help" href="/help/intro.html" target="_blank">Introductory Help In A New Window</a>
<a class="help" href="/help/intro.html" target="_self">Introductory Help</a>
"""

Scenario: A tag with a flag attribute
Given a file named "example_taglib.dryml" with:
"""
<def tag="help-link" attrs="file, new-window">
<a class="help" href="/help/#{file}.html" target="#{new_window ? '_blank' : '_self' }" param="default"/>
</def>
"""
And a file named "example.dryml" with:
"""
<help-link file="intro" new-window>Introductory Help In A New Window</help-link>
<help-link file="intro">Introductory Help</help-link>
"""
When I include the taglib "example_taglib"
And I render "example.dryml"
Then the output DOM should be:
"""
<a class="help" href="/help/intro.html" target="_blank">Introductory Help In A New Window</a>
<a class="help" href="/help/intro.html" target="_self">Introductory Help</a>
"""

Scenario: Using merge-attrs
Given a file named "example_taglib.dryml" with:
"""
<def tag="markdown-help">
<a href="http://daringfireball.net/..." merge-attrs param="default"/>
</def>
"""
And a file named "example.dryml" with:
"""
Add formatting using <markdown-help target="_blank">markdown</markdown-help>
"""
When I include the taglib "example_taglib"
And I render "example.dryml"
Then the output DOM should be:
"""
Add formatting using <a href="http://daringfireball.net/..." target="_blank">markdown</a>
"""

Scenario: Using merge-attrs and attributes_for
Given a file named "example_taglib.dryml" with:
"""
<def tag="help-link" attrs="file, new-window">
<a class="help" href="/help/#{file}.html" target="#{new_window ? '_blank' : '_self' }" param="default"/>
</def>
<def tag="decorated-help" attrs="image, alt">
<help-link merge-attrs="&attributes - attrs_for(:help_link)">
<img src="/images/#{image}.png" alt="#{alt || image}" /><do param="default"/>
</help-link>
</def>
"""
And a file named "example.dryml" with:
"""
<decorated-help image="intro" file="intro" new-window>Introductory Help In A New Window</decorated-help>
"""
When I include the taglib "example_taglib"
And I render "example.dryml"
Then the output DOM should be:
"""
<a class="help" href="/help/.html" target="_self"><img alt="intro" src="/images/intro.png"/>Introductory Help In A New Window</a>
"""

Scenario: Merging the class attribute
Given a file named "example_taglib.dryml" with:
"""
<def tag="help-link" attrs="file">
<a class="help" href="/help/#{file}.html" param="default" merge-attrs/>
</def>
"""
And a file named "example.dryml" with:
"""
<help-link file="intro" class="important">Introductory Help</help-link>
"""
When I include the taglib "example_taglib"
And I render "example.dryml"
Then the output DOM should be:
"""
<a class="help important" href="/help/intro.html">Introductory Help</a>
"""

0 comments on commit 7669361

Please sign in to comment.