Custom Twig Functions for Yves
Edit on GitHubTo improve developer experience, Twig functionality is extended with custom Twig functions. All the Twig extension implementations are located in the ShopUi
module and can be found in ShopUi/src/SprykerShop/Yves/ShopUi/Twig
.
FUNCTION NAME | DESCRIPTION | METHOD SIGNATURE | USAGE EXAMPLE |
---|---|---|---|
publicPath |
|
function publicPath($relativePath: string): string
|
{{ publicPath('css/yves_default.app.css') }} {{ publicPath('js/yves_default.runtime.js') }} |
model |
Resolves a model path and returns a string in the following format:@ShopUi/models/{modelName}.twig . |
function model($modelName: string): string
|
{% extends model('component') %} |
atom |
Resolves an atom path and returns a string in the following format:@{componentModule}/components/atoms/{componentName}/{componentName}.twig . |
function atom($componentName: string, $componentModule: string = ‘ShopUi’): string
|
{% include atom('checkbox') only %} |
molecule |
Resolves a molecule path and returns a string in the following format:@{componentModule}/components/molecules/{componentName}/{componentName}.twig . |
function molecule($componentName: string, $componentModule: string = ‘ShopUi’): string
|
{% extends molecule('card') %} |
organism |
Resolves an organism path and returns a string in the following format:@{componentModule}/components/organisms/{componentName}/{componentName}.twig . |
function organism($componentName: string, $componentModule: string = ‘ShopUi’): string
|
{% include organism('header') only %} |
template |
Resolves a template path and returns a string in the following format:@{templateModule}/templates/{templateName}/{templateName}.twig . |
function template($templateName: string, $templateModule: string = ‘ShopUi’): string
|
{% extends template('widget') %} {% extends template('page-layout-catalog', 'CatalogPage') %} |
view |
Resolves a view path and returns a string in the following format:@{viewModule}/views/{viewName}/{viewName}.twig . |
function view($viewName: string, $viewModule: string = ‘ShopUi’): string
|
{% extends view('voucher-form', 'DiscountWidget') %} |
define |
This function is used for:
|
None | See Usage Example: define below. |
qa |
Returns a string in the following format: data-qa="qa values here". |
function qa($qaValues: string[] = []): string |
{{ qa('submit-button') }} |
qa_* |
Returns a string in the following format: data-qa-name=“{qa values}”. |
function qa_*($qaName: string, $qaValues: string[] = []): string
|
{{ qa_additional('value') }} |
Usage Example: define
{% define data = {
items: _widget.productGroupItems,
} %}
Thank you!
For submitting the form