Skip to content

Commit

Permalink
added experimental t helper to Mojolicious::Plugin::TagHelpers
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 22, 2011
1 parent c669bb7 commit ae93a93
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@ This file documents the revision history for Perl extension Mojolicious.

1.87 2011-08-22 00:00:00
- Added EXPERIMENTAL app method to Mojo::Command.
- Added EXPERIMENTAL t helper to Mojolicious::Plugin::TagHelpers.
- Made tag helper a little smarter.
- Made camelize a little smarter.
- Improved documentation.
Expand Down
12 changes: 12 additions & 0 deletions lib/Mojolicious/Plugin/TagHelpers.pm
Expand Up @@ -233,6 +233,9 @@ sub register {
}
);

# Add "t" helper
$app->helper(t => sub { shift; $self->_tag(@_) });

# Add "tag" helper
$app->helper(tag => sub { shift; $self->_tag(@_) });

Expand Down Expand Up @@ -583,6 +586,15 @@ Generate submit input element.
<input type="submit" value="Ok" />
<input id="foo" type="submit" value="Ok!" />
=head2 C<t>
<%=t div => 'some & content' %>
Alias for C<tag>.
Note that this helper is EXPERIMENTAL and might change without warning!
<div>some &amp; content</div>
=head2 C<tag>
<%= tag 'div' %>
Expand Down
23 changes: 22 additions & 1 deletion t/mojolicious/tag_helper_lite_app.t
Expand Up @@ -7,7 +7,7 @@ BEGIN {
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
}

use Test::More tests => 48;
use Test::More tests => 51;

# "Hey! Bite my glorious golden ass!"
use Mojolicious::Lite;
Expand All @@ -19,6 +19,9 @@ get 'tags';
# GET /more_tags
get 'more_tags';

# GET /small_tags
get 'small_tags';

# GET /links
get 'links';

Expand Down Expand Up @@ -57,6 +60,16 @@ $t->get_ok('/more_tags')->status_is(200)->content_is(<<EOF);
<bar class="test"></bar>
EOF

# GET /small_tags
$t->get_ok('/small_tags')->status_is(200)->content_is(<<EOF);
<div>some &amp; content</div>
<div>
<p id="0">just</p>
<p>0</p>
</div>
<div>works</div>
EOF

# GET /links
$t->get_ok('/links')->status_is(200)->content_is(<<EOF);
<a href="/path">Pa&lt;th</a>
Expand Down Expand Up @@ -295,6 +308,14 @@ __DATA__
%= tag 'bar', class => 'test', 0
%= tag 'bar', class => 'test', ''
@@ small_tags.html.ep
%=t div => 'some & content'
%=t div => begin
%=t p => (id => 0) => 'just'
%=t p => 0
%= end
%=t div => 'works'
@@ links.html.ep
<%= link_to 'Pa<th' => '/path' %>
<%= link_to 'http://example.com/', title => 'Foo', sub { 'Foo' } %>
Expand Down

0 comments on commit ae93a93

Please sign in to comment.