keepsuit/laravel-liquid
最新稳定版本:v0.5.4
Composer 安装命令:
composer require keepsuit/laravel-liquid
包简介
Liquid template engine for Laravel
关键字:
README 文档
README
This is a Laravel view integration of the Shopify Liquid template engine. It uses keepsuit/liquid PHP porting under the hood to parse liquid templates.
Installation
You can install the package via composer:
composer require keepsuit/laravel-liquid
Usage
- Create a liquid template file in
resources/viewsfolder (for examplehome.liquid). - Render the template as usual with Laravel view engine.
class HomeController extends Controller { public function index() { return view('home'); } }
Tags
This package provides some custom tags in addition to the standard Liquid tags.
Auth
Check if the user is authenticated.
Same as laravel @auth directive.
{% auth %}
user is authenticated
{% endauth %}
{% guest %}
user is not authenticated
{% endguest %}
or with custom guard
{% auth('admin') %}
admin is authenticated
{% endauth %}
{% guest 'admin' %}
admin is not authenticated
{% endguest %}
Env
Check if the application environment is the specified one.
Same as laravel @env directive.
{% env 'production' %}
application is in production environment
{% endenv %}
Session
Check if the session has a specific key.
Same as laravel @session directive.
The value of the session key can be accessed with the value variable.
{% session 'status' %}
<div class="p-4 bg-green-100">
{{ value }}
</div>
{% endsession %}
Error
Check if a validation error exists for the given field.
Same as laravel @error directive.
The error message can be accessed with the message variable.
{% error 'email' %}
<div class="text-red-500 text-sm">
{{ message }}
</div>
{% enderror %}
Csrf field
Generate a hidden CSRF token form field.
Same as laravel @csrf directive.
<form method="POST" action="/foo"> {% csrf %} ... </form>
Vite
Adds your vite assets to the template.
Same as laravel @vite directive.
{% vite 'resources/css/app.css', 'resources/js/app.js' %}
{% comment %}With custom build directory{% endcomment %}
{% vite "resources/js/app.js", directory: "custom" %}
Filters
This package provides some custom filters in addition to the standard Liquid filters.
Debug
Debug variable content with dump and dd filters.
{{ variable | dump }}
{{ variable | dd }}
Localization
Translate a string with trans (or t alias) and trans_choice filters using the Laravel localization system.
{{ 'messages.welcome' | trans }}
{{ 'messages.items_count' | trans_choice: 3 }}
Url
Generate urls using the laravel url helpers.
{{ 'app.js' | asset }}
{{ 'app.js' | secure_asset }}
{{ '/home' | url }}
{{ '/home' | secure_url }}
{{ 'home' | route }}
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 7.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-31