Skip to content

Commit

Permalink
[TwigBundle] replaced the asset tag with an asset function (from {% a…
Browse files Browse the repository at this point in the history
…sset css/foo.css %} to {{ asset('css/foo.css') }}
  • Loading branch information
fabpot committed Dec 31, 2010
1 parent 49a3e52 commit 62cd09e
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% block menu %}
<div class="count">{{ '%0.0f'|format(collector.time * 1000) }} ms</div>
<div class="count">{{ collector.querycount }}</div>
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Database" src="{% asset 'bundles/webprofiler/images/db.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Database" src="{{ asset('bundles/webprofiler/images/db.png') }}" />
Doctrine
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% block menu %}
<div class="count">{{ collector.querycount }}</div>
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Mongo" src="{% asset 'bundles/webprofiler/images/db.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Mongo" src="{{ asset('bundles/webprofiler/images/db.png') }}" />
Doctrine MongoDB
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
body { font: 11px Verdana, Arial, sans-serif; color: #333 }
.sf-exceptionreset, .sf-exceptionreset .block, .sf-exceptionreset #message { margin: auto }
</style>
<link href="{% asset 'bundles/framework/css/exception.css' %}" rel="stylesheet" type="text/css" media="screen" />
<link href="{{ asset('bundles/framework/css/exception.css') }}" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
//<![CDATA[
function toggle(id, clazz) {
Expand Down
13 changes: 8 additions & 5 deletions src/Symfony/Bundle/TwigBundle/Extension/TemplatingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public function getFilters()
public function getFunctions()
{
return array(
'url' => new \Twig_Function_Method($this, 'getUrl'),
'path' => new \Twig_Function_Method($this, 'getPath'),
'url' => new \Twig_Function_Method($this, 'getUrl'),
'path' => new \Twig_Function_Method($this, 'getPath'),
'asset' => new \Twig_Function_Method($this, 'getAssetUrl'),
);
}

Expand All @@ -82,6 +83,11 @@ public function getUrl($name, array $parameters = array())
return $this->container->get('router')->generate($name, $parameters, true);
}

public function getAssetUrl($location)
{
return $this->container->get('templating.helper.assets')->getUrl($location);
}

/**
* Returns the token parser instance to add to the existing list.
*
Expand All @@ -102,9 +108,6 @@ public function getTokenParsers()
// {% stylesheets %}
new HelperTokenParser('stylesheets', '', 'templating.helper.stylesheets', 'render'),

// {% asset 'css/blog.css' %}
new HelperTokenParser('asset', '<location>', 'templating.helper.assets', 'getUrl'),

// {% render 'BlogBundle:Post:list' with { 'limit': 2 }, { 'alt': 'BlogBundle:Post:error' } %}
new HelperTokenParser('render', '<template> [with <attributes:hash>[, <options:hash>]]', 'templating.helper.actions', 'render'),

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}

{% block menu %}
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Events" src="{% asset 'bundles/webprofiler/images/events.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Events" src="{{ asset('bundles/webprofiler/images/events.png') }}" />
Events
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{% extends 'WebProfilerBundle:Profiler:layout.twig' %}

{% block head %}
<link href="{% asset 'bundles/framework/css/exception.css' %}" rel="stylesheet" type="text/css" media="screen" />
<link href="{{ asset('bundles/framework/css/exception.css') }}" rel="stylesheet" type="text/css" media="screen" />
{% endblock %}

{% block menu %}
{% if collector.hasexception %}
<span class="count">1</span>
{% endif %}
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Exception" src="{% asset 'bundles/webprofiler/images/exception.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Exception" src="{{ asset('bundles/webprofiler/images/exception.png') }}" />
Exception
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% block menu %}
<span class="count">{{ collector.counterrors }}</span>
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Logs" src="{% asset 'bundles/webprofiler/images/logger.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Logs" src="{{ asset('bundles/webprofiler/images/logger.png') }}" />
Logs
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% endblock %}

{% block menu %}
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Request" src="{% asset 'bundles/webprofiler/images/request.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Request" src="{{ asset('bundles/webprofiler/images/request.png') }}" />
Request
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% endblock %}

{% block menu %}
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Security" src="{% asset 'bundles/webprofiler/images/security.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; width: 32px" width="32" height="32" alt="Security" src="{{ asset('bundles/webprofiler/images/security.png') }}" />
Security
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="import clearfix">
<h3>
<img style="margin: 0 5px 0 0; vertical-align: middle; height: 16px" width="16" height="16" alt="Import" src="{% asset 'bundles/webprofiler/images/import.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; height: 16px" width="16" height="16" alt="Import" src="{{ asset('bundles/webprofiler/images/import.png') }}" />
Admin
</h3>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% block title 'Profiler' %}</title>
<link href="{% asset 'bundles/webprofiler/css/profiler.css' %}" rel="stylesheet" type="text/css" media="screen" />
<link href="{% asset 'bundles/webprofiler/css/toolbar.css' %}" rel="stylesheet" type="text/css" media="screen" />
<link rel="shortcut icon" type="image/x-icon" href="{% asset 'bundles/webprofiler/favicon.ico' %}" />
<link href="{{ asset('bundles/webprofiler/css/profiler.css') }}" rel="stylesheet" type="text/css" media="screen" />
<link href="{{ asset('bundles/webprofiler/css/toolbar.css') }}" rel="stylesheet" type="text/css" media="screen" />
<link rel="shortcut icon" type="image/x-icon" href="{{ asset('bundles/webprofiler/favicon.ico') }}" />
{% block head '' %}
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block body %}
<div class="header">
<h1>
<img alt="" src="{% asset 'bundles/webprofiler/images/profiler.png' %}" />
<img alt="" src="{{ asset('bundles/webprofiler/images/profiler.png') }}" />
Symfony Profiler
</h1>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block body %}
<div class="header">
<h1>
<img alt="" src="{% asset 'bundles/webprofiler/images/profiler.png' %}" />
<img alt="" src="{{ asset('bundles/webprofiler/images/profiler.png') }}" />
Symfony Profiler
</h1>
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="search clearfix">
<h3>
<img style="margin: 0 5px 0 0; vertical-align: middle; height: 16px" width="16" height="16" alt="Search" src="{% asset 'bundles/webprofiler/images/search.png' %}" />
<img style="margin: 0 5px 0 0; vertical-align: middle; height: 16px" width="16" height="16" alt="Search" src="{{ asset('bundles/webprofiler/images/search.png') }}" />
Search
</h3>
<form action="{{ path('_profiler_search') }}" method="get">
Expand Down

0 comments on commit 62cd09e

Please sign in to comment.