mangoweb/latte-bundle
Composer 安装命令:
composer require mangoweb/latte-bundle
包简介
Latte templating engine for Symfony
README 文档
README
How to install
- Just install it as standard symfony bundle
- Then just ask for
Latte\Engineservice
Latte
Symfony specific macros
renderRoute
Makes a request to the given route and prints the result.
Spec
{renderRoute <routeName>[, 'routeParams'=>[(<key> => <value>,)...][, 'renderOptions'=>[(<key> => <value>,)...]}
Example
{renderRoute myAwesomeRoute,'routeParams'=>['x' => 5, 'y' => 7],'renderOptions'=>['strategy' => 'inline']}
routePath
Print the relative URL (without the scheme and host) for the given route.
Spec
{routePath <routeName>[,<key> => <value>]...}
<a n:href="<routeName>[,<key> => <value>]...">
Example
{routePath myAwesomeRoute,'x' => 5,'y' => 7}
<a n:href="myAwesomeRoute,'x' => 5,'y' => 7"></a>
routeUrl
Print the absolute URL (with scheme and host) for the given route.
Spec
{routeUrl <routeName>[,<key> => <value>]...}
Example
{routeUrl myAwesomeRoute,'x' => 5,'y' => 7}
relativePath
Returns the relative path from the passed absolute URL. See Symfony doc - relative_path
Spec
{relativePath <absoluteUrl>}
Example
{relativePath 'http://example.com/human.txt'}
absoluteUrl
Returns the absolute URL from the passed relative path.
Spec
{absoluteUrl <relativePath>}
Example
{absoluteUrl 'human.txt'}
csrfToken
Renders a CSRF token. Use this function if you want CSRF protection without creating a form.
Spec
{csrfToken <intention>}
logoutUrl - logoutPath
Generates a absolute/relative logout URL for the given firewall. If no key is provided, the URL is generated for the current firewall the user is logged into.
Spec
{logoutPath [key]}
{logoutUrl [key]}
Symfony filters
translate
See Symfony docs - translation in templates
Spec
{="<translation.key>"|translate[:[(<argumentName> => <argumentValue>,)...]][:<domain>][:<locale>]}
{_"<translation.key>"}
domain- string, optionallocale- string, optional
Example
{="my.awesome.translation.key"|translate:['%name%' => 'Karel','%job%' => 'Metař']} {="my.awesome.translation.key"}
translateChoice
See Symfony docs - translation in templates
Spec
{="<translation.key>"|translateChoice:<count>[:[(<argumentName> => <argumentValue>,)...]][:<domain>][:<locale>]}
count- int, requireddomain- string, optionallocale- string, optional
Example
{="my.awesome.translation.key"|translateChoice:5:['%name%' => 'Karel','%job%' => 'Metař']}
How to expand
Macros
Simple macro
- Class
\Mangoweb\LatteBundle\Macro\SimpleMacrois wrapper for macroSet->addMacro() (see https://latte.nette.org/en/#toc-user-defined-macros) - Extend class and mark service with service tag
- { name: latte.simple_macro } - Or Implement
\Mangoweb\LatteBundle\Macro\ISimpleMacroProviderand mark it with service tag- { name: latte.simple_macro_provider }
Advanced macro
- Implement directly
\Latte\IMacro - Register service and mark it with service tag
- { name: latte.advanced_macro, macro_name: fooBar }
Filters
Filter provider
- Implement
\Mangoweb\LatteBundle\Filter\IFilterProvider - Mark service with service tags:
{name: 'latte.filter_provider'}
Providers
- Create service and tag it with
- {name: 'latte.provider', provider_name: fooBar } - This will then be avabile at runtime in latte via
$this->global->fooBar
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-12