Twig-based PatternEngine for Pattern Lab.

Overview

Twig PatternEngine for Pattern Lab

The Twig PatternEngine allows you to use Twig as the template language for Pattern Lab PHP. Once the PatternEngine is installed you can use Twig-based StarterKits and StyleguideKits.

Installation

The Twig PatternEngine comes pre-installed with the Pattern Lab Standard Edition for Twig. Please start there for all your Twig needs.

Composer

Pattern Lab PHP uses Composer to manage project dependencies with Pattern Lab Editions. To add the Twig PatternEngine to the dependencies list for your Edition you can type the following in the command line at the base of your project:

composer require pattern-lab/patternengine-twig

See Packagist for information on the latest release.

Overview

This document is broken into three parts:

Working with Patterns and Twig

Twig provides access to two features that may help you extend your patterns, macros and layouts viatemplate inheritance. The Twig PatternEngine also supports the pattern partial syntax to make including one pattern within another very easy.

Pattern includes

Pattern includes take advantage of the pattern partial syntax as a shorthand for referencing patterns from across the system without needing to rely on absolute paths. The format:

{% include "[patternType]-[patternName]" %}

For example, let's say we wanted to include the following pattern in a molecule:

source/_patterns/00-atoms/03-images/02-landscape-16x9.twig

The pattern type is atoms (from 00-atoms) and the pattern name is landscape-16x9 from (from 02-landscape-16x9.twig). Pattern sub-types are never used in this format and any digits for re-ordering are dropped. The shorthand partial syntax for this pattern would be:

{% include "atoms-landscape-16x9" %}

Macros

The requirements for using macros with Pattern Lab:

  • Files must go in source/_macros
  • Files must have the extension .macro.twig (this can be modified in the config)
  • The filename will be used as the base variable name in Twig templates

Please note: ensure that there is no overlap between the keys for your macros and the keys for your data attributes. A macro with the name forms.macro.twig will conflict with a root key with the name forms in your JSON/YAML. Both are accessed via {{ forms }} in Twig.

An example of a simple macro called forms.macro.twig in source/_macros:

{% macro input(name) %}
    <input type="radio" name="{{ name }}" value="Dave" /> {{ name }}
{% endmacro %}

Would be used like this in a pattern:

{{ forms.input("First name") }}

Template inheritance

How to use Template Inheritance with Pattern Lab:

  • Files must have the extension .twig.
  • Files can be extended either by using Pattern Lab's normal shorthand syntax (e.g, {% extends 'templates-extended-layout'%}).
  • Files can optionally go in source/_layouts in order to hide them from the list of patterns and then you can just use the filename as reference (e.g., {% extends 'extended-layout'%}).
  • Files that are in the same directory can also just use the file name without the shorthand syntax (however, it must include the extension). So if file1.twig and file2.twig were in same directory, you could place this code in file2.twig: {% extends 'file1.twig' %}.

An example of a simple layout called base.twig in source/_layouts:

<!DOCTYPE html>
<html>
    <head>
        {% block head %}
            <link rel="stylesheet" href="style.css" />
            <title>{% block title %}{% endblock %} - My Webpage</title>
        {% endblock %}
    </head>
    <body>
        <div id="content">{% block content %}{% endblock %}</div>
        <div id="footer">
            {% block footer %}
                &copy; Copyright 2011 by <a href="http://domain.invalid/">you</a>.
            {% endblock %}
        </div>
    </body>
</html>

Would be used like this in a pattern:

{% extends "base.twig" %}

{% block title %}Index{% endblock %}
{% block head %}
    {{ parent() }}
    <style type="text/css">
        .important { color: #336699; }
    </style>
{% endblock %}
{% block content %}
    <h1>Index</h1>
    <p class="important">
        Welcome on my awesome homepage.
    </p>
{% endblock %}

All uses of extends above also work with includes, embed and most likely many other Twig Tags. Let us know if you run into interesting or unexpected use cases!

Extending Twig Further

Twig comes with a number of ways to extend the underlying template parser. You can you can add extra tags, filters, tests, and functions. The Twig PatternEngine tries to simplify these extensions by allowing you to create files in specific folders and then auto-load the extensions for you. Learn more about:

You can also:

Filters

The requirements for using filters with Pattern Lab:

  • Files must go in source/_twig-components/filters
  • Files must have the extension .filter.php (this can be modified in the config)
  • The filter must set the variable $filter
  • Only one filter per file (e.g. can only set $filter once per file)

An example function called rot13.filter.php in source/_twig-components/filters:

<?php

$filter = new Twig_SimpleFilter('rot13', function ($string) {
	return str_rot13($string);
});

?>

This filter would be used like this in a pattern:

{{ bar|rot13 }}

Functions

The requirements for using functions with Pattern Lab:

  • Files must go in source/_twig-components/functions
  • Files must have the extension .function.php (this can be modified in the config)
  • The function must set the variable $function
  • Only one function per file (e.g. can only set $function once per file)

An example function called boo.function.php in source/_twig-components/functions:

<?php

$function = new Twig_SimpleFunction('boo', function ($string) {
	return $string." boo! ";
});

?>

This function would be used like this in a pattern:

{{ boo("ghost says what?") }}

Tests

The requirements for using tests with Pattern Lab:

  • Files must go in source/_twig-components/tests
  • Files must have the extension .test.php (this can be modified in the config)
  • The test must set the variable $test
  • Only one test per file (e.g. can only set $test once per file)

An example of a simple test called red.test.php in source/_twig-components/tests:

<?php

$test = new Twig_SimpleTest('red', function ($value) {
	
	if (isset($value["color"]) && $value["color"] == 'red') {
		return true;
	}
	
	return false;
});

?>

This test would be used like this in a pattern:

{% if shirt is red %}
	Why did I ever sign-up with Starfleet?
{% endif %}

Where the JSON for the data to set shirt would be:

"shirt": {
	"color": "red"
}

Reminder: all data in Pattern Lab is stored as an array and not as an object. So $object->attribute won't work in tests.

Tags

The requirements for using tags with Pattern Lab:

  • Files must go in source/_twig-components/tags
  • Files must have the extension .tag.php (this can be modified in the config)
  • The filename must be reflected in class names. (e.g. Project_{filename}_Node and Project_{filename}_TokenParser)
  • Only one tag per file

Tags are the most complicated extension to set-up with Pattern Lab. Three steps are needed to define a new tag in Twig:

  • Defining a Token Parser class (responsible for parsing the template code)
  • Defining a Node class (responsible for converting the parsed code to PHP)
  • Registering the tag.

Pattern Lab takes care of the registering for you based on the file name.

An example of a simple tag called setdupe.tag.php in source/_twig-components/tags that mimics the default set tag. Please note all of the locations where class names incorporate the filename, setdupe.

<?php

// these files are loaded three times and we can't re-set a class
if (!class_exists("Project_setdupe_Node")) {
	
	class Project_setdupe_Node extends Twig_Node {
		
		public function __construct($name, Twig_Node_Expression $value, $line, $tag = null) {
			parent::__construct(array('value' => $value), array('name' => $name), $line, $tag);
		}
		
		public function compile(Twig_Compiler $compiler) {
			$compiler
				->addDebugInfo($this)
				->write('$context[\''.$this->getAttribute('name').'\'] = ')
				->subcompile($this->getNode('value'))
				->raw(";\n");
		}
		
	}
	
}

// these files are loaded three times and we can't re-set a class
if (!class_exists("Project_setdupe_TokenParser")) {
	
	class Project_setdupe_TokenParser extends Twig_TokenParser {
		
		public function parse(Twig_Token $token) {
			
			$parser = $this->parser;
			$stream = $parser->getStream();
			
			$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
			$stream->expect(Twig_Token::OPERATOR_TYPE, '=');
			$value = $parser->getExpressionParser()->parseExpression();
			$stream->expect(Twig_Token::BLOCK_END_TYPE);
			
			return new Project_setdupe_Node($name, $value, $token->getLine(), $this->getTag());
		}
		
		public function getTag() {
			return 'setdupe';
		}
		
	}
	
}

?>

This tag would be used like this in a pattern:

{% setdupe name = "Ziggy" %}
{{ name }}

Adding a custom Twig Extension

A Twig Extension is a collection of Twig functions, filters, tags, globals, and tests all as a single bundle. This approach is more advanced than adding a single function or filter using the above method, but allows greater flexibility as the whole Twig Extension can be installed in multiple environments.

To add a Twig Extension using the PHP class \MyProject\MyCustomTwigExtension, add this to config.yml:

twigExtensions:
    - '\MyProject\MyCustomTwigExtension'

What happens under the hood is basically this:

$twig = new Twig_Environment($loader);

foreach ($twigExtensions as $twigExtension) {
    $twig->addExtension(new $twigExtension());
}

If two Twig Extensions declare a function, filter, etc; the later ones override earlier ones. Any ones declared in Pattern Lab's _twig-components folder will override any declared using this method of custom Twig Extensions.

For an example of how this works, see ExampleTwigExtension.php in this repo. You can enable it by adding this to your config.yml:

twigExtensions:
    - '\PatternLab\PatternEngine\Twig\ExampleTwigExtension'

Then place this in any Twig file:

<p>Testing: {{ testPlFunction('testing...') }}</p>

That function declaration looks like this in ExampleTwigExtension.php:

new Twig_SimpleFunction('testPlFunction', function($arg) {
    return 'Thanks for testing out the Pattern Lab Example Twig Extension with this arg: ' . $arg;
}),

An incredible amount of exciting possibilities are enabled with this; have fun!

Enable dump()

To use dump() set twigDebug in config/config.yml to true.

Modify the Default Date and Interval Formats

You can modify the default date and interval formats for Twig by editing the twigDefaultDateFormat and twigDefaultIntervalFormat in config/config.yml. Set them to an empty string to use Twig's default formats. Please note: both must be set for this feature to work.

Quickly Disable Extensions

To disable extensions that you're no longer using simply add an underscore to the beginning of a filename and then re-generate your site. For example, the enabled rot13 filter:

source/_twig-components/filters/rot13.filter.php

And the disabled rot13 filter:

source/_twig-components/filters/_rot13.filter.php

Then re-generate your Pattern Lab site with:

php core/console --generate

Available Loaders

If you're building a plugin that will be parsing Twig files you have access to three loaders. It's recommended that you use these instead of accessing Twig directly as these loaders will work with other PatternEngines.

The String Loader

The string loader takes a simple string and compiles it. To use:

$data         = array("hello" => "world");
$string       = "If I say hello you say {{ hello }}.";
$stringLoader = \PatternLab\Template::getStringLoader();
$output       = $stringLoader->render(array("string" => $string, "data" => $data));
print $output; // outputs "If I say hello you say world."

The Filesystem Loader

The filesystem loader will look for templates in the configured StyleguideKit directory and compile them. The template location for the filesystem loader can't be modified. To use:

$data             = array(...);
$filesystemLoader = \PatternLab\Template::getFilesystemLoader();
$output           = $filesystemLoader->render(array("template" => "viewall", "data" => $data));
print $output; // outputs the viewall view from the configured styleguidekit

The Pattern Loader

The pattern loader looks for patterns and allows the use of the Pattern Lab-specific partial syntax. To use:

$data                  = array(...);
$patternContent        = file_get_contents("path/to/pattern");
$patternEngineBasePath = \PatternLab\PatternEngine::getInstance()->getBasePath();
$patternLoaderClass    = $patternEngineBasePath."\Loaders\PatternLoader";
$patternLoader         = new $patternLoaderClass($options);
$code                  = $patternLoader->render(array("pattern" => $patternContent, "data" => $data));
print $output; // outputs the given pattern
Comments
  • Tag embed not working anymore

    Tag embed not working anymore

    The commit https://github.com/pattern-lab/patternengine-php-twig/commit/b5ed124547944abc7a0d5ad70be2523b60c63934 prevents using the Tag embed. The Solution is to add another Node Visitor EmbedNodeVisitor which creates an PatternDataEmbedNode exending Twig_Node_Embed. In Addition prevent in the IncludeNodeVisitor creating a PatternDataIncludeNode class in case the $node is an object of Twig_Node_Embed. Something like if ($node instanceof \Twig_Node_Include && !($node instanceof \Twig_Node_Embed)) {

    bug 
    opened by schauer 10
  • Clarify how listItems work with Twig

    Clarify how listItems work with Twig

    I have been unable to find a way to generate a list of patterns as can be done in Mustache: http://patternlab.io/docs/data-listitems.html

    When I have tried creating a listitems.json file for a particular pattern, like topic.listitems.json, I get an error like so:

    configuring pattern lab... PHP Fatal error: Call to protected method PatternLab\Data::getListItems() from context 'PatternLab\PatternData\Rules\PatternInfoListItemsRule' in /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php on line 54 PHP Stack trace: PHP 1. {main}() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/core/console:0 PHP 2. PatternLab\Console::run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/core/console:46 PHP 3. PatternLab\Console\Commands\GenerateCommand->run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Console.php:83 PHP 4. PatternLab\Generator->generate() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Console/Commands/GenerateCommand.php:41 PHP 5. PatternLab\PatternData::gather() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Generator.php:69 PHP 6. PatternLab\PatternData\Rules\PatternInfoListItemsRule->run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/PatternData.php:139

    Fatal error: Call to protected method PatternLab\Data::getListItems() from context 'PatternLab\PatternData\Rules\PatternInfoListItemsRule' in /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php on line 54

    Call Stack: 0.0033 237016 1. {main}() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/core/console:0 0.0416 1139488 2. PatternLab\Console::run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/core/console:46 0.0467 1285960 3. PatternLab\Console\Commands\GenerateCommand->run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Console.php:83 0.0874 2896088 4. PatternLab\Generator->generate() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Console/Commands/GenerateCommand.php:41 0.0925 3262920 5. PatternLab\PatternData::gather() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Generator.php:69 0.1008 3690656 6. PatternLab\PatternData\Rules\PatternInfoListItemsRule->run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/PatternData.php:139

    Warning: Command failed: PHP Fatal error: Call to protected method PatternLab\Data::getListItems() from context 'PatternLab\PatternData\Rules\PatternInfoListItemsRule' in /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php on line 54 PHP Stack trace: PHP 1. {main}() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/core/console:0 PHP 2. PatternLab\Console::run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/core/console:46 PHP 3. PatternLab\Console\Commands\GenerateCommand->run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Console.php:83 PHP 4. PatternLab\Generator->generate() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Console/Commands/GenerateCommand.php:41 PHP 5. PatternLab\PatternData::gather() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/Generator.php:69 PHP 6. PatternLab\PatternData\Rules\PatternInfoListItemsRule->run() /Library/WebServer/Documents/sitename/docroot/sites/sitename/themes/themename/patternlab/vendor/pattern-lab/core/src/PatternLab/PatternData.php:139 Use --force to continue.

    opened by RainbowArray 9
  • Location of files used for inheritance

    Location of files used for inheritance

    @dmolsen @EvanLovely -

    The README states that files used for template inheritance (i.e., the extends tag), must go in source/_layouts.

    However, in commit 16fe2ba of pattern-lab/patternengine-php-twig, the 01-homepage.twig template extend 00-site.twig from the _patterns/03-templates directory, not the _layouts directory.

    Is this now possible? If so, the README should be changed.

    opened by TxHawks 6
  • Consider turning off escaping strategy

    Consider turning off escaping strategy

    By default, Twig has the escaping strategy set to html, meaning that HTML tags are automatically escaped. Does this escaping strategy make sense in the context of Pattern Lab? I would argue that as a developer, I should be able to put whatever I want into my data.json file (including HTML) without having to explicitly escape it. Hence, it makes sense to me to disable the escaping strategy alltogether.

    enhancement 
    opened by nmeirik 6
  • Provide a way to register a Twig_ExtensionInterface

    Provide a way to register a Twig_ExtensionInterface

    Especially for use cases where many StarterKits use the same Twig extensions it would be good to be able to register a class implementing Twig_ExtensionInterface.

    enhancement 
    opened by aleksip 5
  • Question regarding commiting patterns

    Question regarding commiting patterns

    I'm starting our first project using Pattern Lab and I can't tell what I should commit for my team. The Twig build came with a .gitignore file that had the following:

    .DS_Store
    composer.lock
    config/*
    export/*
    packages/*
    public/*
    source/*
    vendor/*
    

    It seems that at the very least, source/* should be committed if this is to be shared and multiple devs are to contribute. It also seems that config, packages, and vendor are needed for building correctly. I'm not sure what export is.

    In public, I'm pretty sure I can ignore everything since it does seem to all build just fine from scratch. We can build on individual local machines as well as on the server.

    So is this more like what should be ignored? For a team working on it together?

    .DS_Store
    composer.lock
    public/annotations/
    public/css/
    public/images/
    public/js/
    public/patternlab-components/
    public/patterns/
    public/
    public/favicon.ico
    

    Is there another workflow that I'm missing? If there's a resource about this somewhere I haven't been able to find it but I'd be happy to simply be pointed there.

    Also posted to SO after posting here since I'm not sure of the level of activity here. Will update here if there's a response there.

    opened by abea 3
  • Import variables from several jsons

    Import variables from several jsons

    Is it possible to import variables for a pattern from several json files? I'm building a rather complex app where a page inherits from the section it reside in.

    I'd like to have json files for each section and do something like:

    // article~news.json
    {
      "section": "news"
    }
    
    {# article.twig#}
    {% if section == "news" %}
      {# code to import variables from '_data/section-news.json' #}
    {% endif %}
    
    opened by TxHawks 3
  • Example on how to load extensions?

    Example on how to load extensions?

    Hi,

    I notice that there is documentation on how to exend the pattern lab to add your own filters, functions, and tags. But there is also an extensions directory under _twig-components, but there is no example at all on how to load an extension.

    Could one be added?

    Thanks!

    question 
    opened by iandevlin 2
  • Add support for custom filters

    Add support for custom filters

    This feature would work in a similar way to the Mustache Helper feature. Twig helpers could be installed via composer and they'd register themselves. Currently this is how the Mustache helper works:

    • install helper which gets registered
    • on load the helper is associated with a dispatcher event
    • when the pattern engine loads it fires the event and all helpers register themselves

    Example mustache helper.

    enhancement 
    opened by dmolsen 2
  • Mega PR: Merging Drupal Pattern Lab's Twig Pattern Engine Fork Back Into the Main Pattern Lab PHP Twig Pattern Engine Repo

    Mega PR: Merging Drupal Pattern Lab's Twig Pattern Engine Fork Back Into the Main Pattern Lab PHP Twig Pattern Engine Repo

    This folds in the past 5 months worth of maintenance and enhancement updates made to the Drupal Pattern Lab working group's ongoing Pattern Lab PHP Core and Pattern Lab Twig Engine (this repo) forks as part of the new exciting updates @bradfrost posted about earlier this week!

    Changelog:

    • FIX: Fix long broken lineage functionality when using Twig namespaces (ie. Drupal 8 friendly paths) + picks up extends and embeds as lineages as well. Closes out #105 and related to the #129 Mega Issue | @sghoweri and @aleksip
    • CHORE: Merge Pattern Lab Twig Engine dev work @dmolsen helped with back in May of 2016 | @dmolsen, @EvanLovely and @sghoweri

    TODOs

    • [ ] remove references to Drupal Pattern Lab in composer.json
    • [ ] move existing PRs / Issues over to main Pattern Engine PHP Twig repo
    opened by sghoweri 1
  • Code inspector does not display html tags under twig tab, says 'file not found' under html tab

    Code inspector does not display html tags under twig tab, says 'file not found' under html tab

    When looking at the code for an individual pattern, we only see twig directives and raw text under the twig tab, such as

    {% include "atoms-hero" %}
    
    
    
    
            Strategic collaboration
    
    
    
    

    Notice the indentation that suggests the html hierarchy of the template, but no tags or classes displayed.

    The html tab is even less instructive, simply declaring file doesn't exist.

    Installed version of pattern-lab-core is 2.7.0, patternengine-php-twig is 2.0.0

    opened by mathieuhelie 1
  • Add twigEnvironmentClass config to allow custom Twig environments

    Add twigEnvironmentClass config to allow custom Twig environments

    During the development of https://www.drupal.org/project/drupal/issues/3064854, it became clear that Pattern Lab will need a way to allow a plugin such as https://github.com/pattern-lab/plugin-drupal-twig-components to specify a custom Twig environment to allow for certain functionality to be added.

    opened by markhalliwell 0
  • How to use shorthand syntax outside of patternlab itself?

    How to use shorthand syntax outside of patternlab itself?

    Hi,

    Thanks for all the work that's gone into this project!

    I was hoping to use the shorthand include syntax outside of Pattern Lab (in Drupal as it happens). I found the same request from 2016 in https://github.com/pattern-lab/edition-php-twig-standard/issues/18. In that issue there's a workaround suggested and the issue was closed.

    I was just wondering if there was any interest in trying to go further and make the pattern partial loader itself available to consumers such as Drupal? I've done a simple PoC that seems to work for me:

    1. pattern-lab-php-path-src-exporter: A PL listener that dumps the pattern paths data (ie the second argument to \PatternLab\PatternEngine\Twig\Loaders\Twig\PatternPartialLoader::__construct()) to a file.
    2. patternlabloader: A Drupal module that extends PatternPartialLoader to read the location of the pattern paths data file from the theme info file, and use it to construct the loader.

    I'm quite new to Pattern Lab, maybe there's a better way to do this? At the moment a pain point is obviously that to get the partial loader and utility class you need patternengine-twig which needs core + deps, and really this is all for two classes: \PatternLab\PatternEngine\Twig\Loaders\Twig\PatternPartialLoader and \PatternLab\PatternEngine\Util.

    Would there be any chance we could grab the pattern partial loader without the rest of pattern lab? Any advice/suggestions?

    Thanks for your time and consideration!

    opened by andriokha 3
  • Add twigStrictVariables option

    Add twigStrictVariables option

    Enable setting strict_variables mode in Twig which helps to minimize build errors when components and patterns are used withing a Twig 2.0 (#41) environment.

    To use, one can set twigStrictVariables: true in the patternlab config.

    opened by renestalder 1
  • Attributes in macros are double quoted

    Attributes in macros are double quoted

    • this is using aleksip/plugin-data-transform for attributes

    This is working fine in a pattern: <div {{ attributes.addClass('test') }}>test</div> <div class="test">test</div>

    But if this is inside a macro, I get: <div class=""test"">test</div>

    I can work around this by including the macro file like another pattern.

    opened by mortona42 0
  • "twigMacroExt": "macro.twig" in composer.json should be "twigMacroExt": "macro.php"

    I was running into problems where the terminal told me: Fatal error: Call to undefined method _TwigTemplate ....

    After some research I found this issue has been allready described there: https://github.com/pattern-lab/starterkit-twig-demo/issues/15#issuecomment-432955110

    Please correct me if I'm wrong.

    opened by jirmueller 0
Releases(v2.2.2)
Need some filters? This package is based on the Repository Design Pattern to let you create specific queries easily.

DevMakerLab/Laravel-Filters Need some filters? This package is based on the Repository Design Pattern to let you create specific queries easily. Insta

DevMakerLab 19 Feb 20, 2022
Fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent Resources, Translatability, and Swagger.

Laravel Headless What about? This allows a fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent R

Julien SCHMITT 6 Dec 30, 2022
Allows you to use Twig seamlessly in Laravel

Allows you to use Twig seamlessly in Laravel. Requirements TwigBridge >= 0.13 supports Twig 3. If you need Twig 1/2 support, use the 0.12 versions. In

Rob Crowe 877 Dec 30, 2022
Give the power of Twig to Laravel

Allows you to use Twig seamlessly in Laravel. Requirements TwigBridge >= 0.13 supports Twig 3. If you need Twig 1/2 support, use the 0.12 versions. In

Rob Crowe 866 Jan 30, 2022
A package to implement repository pattern for laravel models

Laravel Model UUID A simple package to use Repository Pattern approach for laravel models . Repository pattern Repositories are classes or components

null 26 Dec 21, 2022
Repository Pattern implementation for Laravel

This is a Simple Repository Pattern implementation for Laravel Projects and an easily way to build Eloquent queries from API requests.

Ephraïm SEDDOR 1 Nov 22, 2021
Auto-generated Interface and Repository file via Repository pattern in Laravel

Auto-generated Repository Pattern in Laravel A repository is a separation between a domain and a persistent layer. The repository provides a collectio

Ngo Dinh Cuong 11 Aug 15, 2022
Laravel Design Pattern Generator (api generator)

Laravel Design Pattern Generator (api generator) you can create your restful api easily by using this library and you can filter, sort and include elo

HusseinAlaa 2 Sep 25, 2022
🖖Repository Pattern in Laravel. The package allows to filter by request out-of-the-box, as well as to integrate customized criteria and any kind of filters.

Repository Repository Pattern in Laravel. The package allows to filter by request out-of-the-box, as well as to integrate customized criteria and any

Awes.io 160 Dec 26, 2022
A lightweight domain event pattern implementation for Doctrine2.

Knp Rad Domain Event A lightweight domain event pattern implementation for Doctrine2. Official maintainers: @Einenlum Installation With composer : $ c

KNP Labs 5 Sep 23, 2022
Laravel specification pattern

Laravel specification pattern Filter an Illuminate collection with specifications. Installation You can install the package via composer: composer req

Maarten Paauw 5 Nov 30, 2022
A straightforward implementation of the Circuit Breaker pattern for Laravel 9

Laravel Circuit Breaker A straightforward implementation of the Circuit Breaker pattern for Laravel Framework 9 (using Memcached). Installation You ca

Leonardo Vieira 2 Mar 22, 2022
States allows you to create PHP classes following the State Pattern in PHP.

States allows you to create PHP classes following the State Pattern in PHP. This can be a cleaner way for an object to change its behavior at runtime without resorting to large monolithic conditional statements and this improve maintainability and workflows writing.

Teknoo Software 10 Nov 20, 2022
Awes.io // boilerplate based on Vue, Nuxt, TailwindCSS plus Laravel as a backend. 🤟

Platform for Interactive Business Applications 10x faster to create than the traditional way • 3x increase application experiences • 60% decrease in d

Awes.io 753 Dec 30, 2022
Determine the geographical location of website visitors based on their IP addresses.

GeoIP for Laravel Determine the geographical location and currency of website visitors based on their IP addresses. GeoIP for Laravel on Packagist Geo

Daniel Stainback 1.9k Jan 6, 2023
Ubilling is opensource ISP billing system based on stargazer

Ubilling Ubilling is opensource ISP billing system based on stargazer. Please visit our official resources: Project homepage Documentation Community f

Rostyslav 105 Dec 5, 2022
PHP package to help the development of Laravel-based Telegram bots

Laravel-telegram-bot Project description goes here. This description is usually two to three lines long. It should give an overview of what the projec

CC - UFFS 6 May 10, 2021
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css

Laravel Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size WITHOUT cs

Tina Hammar 7 Nov 23, 2022
MediaDB is a web-based media streaming service written in Laravel and Vue.

MediaDB (API) MediaDB is a web-based media streaming service written in Laravel and Vue. The nginx-vod-module is used for on-the-fly repackaging of MP

François M. 53 Sep 3, 2022