Skip to content

Commit

Permalink
deprecated base_tag helper (closes #437)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 4, 2013
1 parent 6397b63 commit 5e59bd9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

3.72 2013-01-04
3.72 2013-01-05
- Deprecated base_tag helper.
- Improved documentation.

3.71 2013-01-02
Expand Down
16 changes: 6 additions & 10 deletions lib/Mojolicious/Plugin/TagHelpers.pm
Expand Up @@ -13,9 +13,13 @@ sub register {
$app->helper("${name}_field" => sub { _input(@_, type => $name) });
}

# Add "base_tag" helper
# DEPRECATED in Rainbow!
$app->helper(
base_tag => sub { _tag('base', href => shift->req->url->base, @_) });
base_tag => sub {
warn "base_tag is DEPRECATED!!!\n";
_tag('base', href => shift->req->url->base, @_);
}
);

# Add "checkbox" helper
$app->helper(check_box =>
Expand Down Expand Up @@ -299,14 +303,6 @@ example for learning how to build new plugins, you're welcome to fork it.
L<Mojolicious::Plugin::TagHelpers> implements the following helpers.
=head2 C<base_tag>
%= base_tag
Generate portable C<base> tag refering to the current base URL.
<base href="http://localhost/cgi-bin/myapp.pl" />
=head2 C<check_box>
%= check_box employed => 1
Expand Down
4 changes: 2 additions & 2 deletions t/mojolicious/lite_app.t
Expand Up @@ -893,7 +893,7 @@ $t->get_ok('/foo_wildcard_too/')->status_is(404);
# GET /with/header/condition
$t->get_ok('/with/header/condition',
{'X-Secret-Header' => 'bar', 'X-Another-Header' => 'baz'})->status_is(200)
->content_like(qr!^Test ok<base href="http://localhost!);
->content_is("Test ok!\n");

# GET /with/header/condition (missing headers)
$t->get_ok('/with/header/condition')->status_is(404)->content_like(qr/Oops!/);
Expand Down Expand Up @@ -1268,7 +1268,7 @@ text!
<%= $self->match->endpoint->name %>
@@ with_header_condition.html.ep
Test ok<%= base_tag %>
Test ok!
@@ root.html.epl
% my $self = shift;
Expand Down
12 changes: 6 additions & 6 deletions t/mojolicious/rebased_lite_app.t
Expand Up @@ -47,7 +47,7 @@ my $t = Test::Mojo->new;
# GET /
$t->get_ok('/')->status_is(200)->header_is('X-Route' => 'root')
->content_is(<<EOF);
<base href="http://kraih.com/rebased/" />
http://kraih.com/rebased/
<script src="/rebased/js/jquery.js"></script>
<img src="/rebased/images/test.png" />
http://kraih.com/rebased/foo
Expand All @@ -60,7 +60,7 @@ EOF
# GET /foo
$t->get_ok('/foo')->status_is(200)->header_is('X-Route' => 'foo')
->content_is(<<EOF);
<base href="http://kraih.com/rebased/" />
http://kraih.com/rebased/
<link href="/rebased/b.css" media="test" rel="stylesheet" />
<img alt="Test" src="/rebased/images/test.png" />
http://kraih.com/rebased
Expand All @@ -78,7 +78,7 @@ ok $t->ua->cookie_jar->find($t->ua->app_url->path('/foo')), 'session cookie';

# GET /foo (with flash message)
$t->get_ok('/foo')->status_is(200)->content_is(<<EOF);
<base href="http://kraih.com/rebased/" />works!too!
http://kraih.com/rebased/works!too!
<link href="/rebased/b.css" media="test" rel="stylesheet" />
<img alt="Test" src="/rebased/images/test.png" />
http://kraih.com/rebased
Expand All @@ -90,7 +90,7 @@ EOF
# GET /baz
$t->get_ok('/baz')->status_is(200)->header_is('X-Route' => 'baz')
->content_is(<<EOF);
<base href="http://kraih.com/rebased/" />
http://kraih.com/rebased/
<script src="/rebased/js/jquery.js"></script>
<img src="/rebased/images/test.png" />
http://kraih.com/rebased/foo
Expand All @@ -106,7 +106,7 @@ done_testing();

__DATA__
@@ root.html.ep
%= base_tag
%= $self->req->url->base
%= javascript '/js/jquery.js'
%= image '/images/test.png'
%= url_for('foo')->to_abs
Expand All @@ -118,7 +118,7 @@ __DATA__
% }
@@ foo.html.ep
<%= base_tag %><%= flash 'just' || '' %><%= flash 'works' || '' %>
<%= $self->req->url->base %><%= flash 'just' || '' %><%= flash 'works' || '' %>
%= stylesheet '/b.css', media => 'test'
%= image '/images/test.png', alt => 'Test'
%= url_for('root')->to_abs
Expand Down

0 comments on commit 5e59bd9

Please sign in to comment.