2017 © Pedro Peláez
 

library twig-tools

image

basaltinc/twig-tools

  • Saturday, March 31, 2018
  • by EvanLovely
  • Repository
  • 2 Watchers
  • 1 Stars
  • 14,423 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 18 Versions
  • 54 % Grown

The README.md

Twig Tools by Basalt

composer require basaltinc/twig-tools

Twig Functions

get_data( path )

Takes the path to a .json, .yml, or .yaml file and returns the data for use in Twig., (*1)

Parameters

  • path {string} Either absolute path, relative path from CWD, or Twig Namespace path like @namespace/file.json.

Example

{% set schema = get_data('@namespace/foobar.schema.yml') %}

validate_data_schema( path, _self )

Takes the path to a .json, .yml, or .yaml data schema file and validates the data being used by the twig template file in which the validate function is included. As a standard, this should be the last thing included in a twig template file., (*2)

Parameters

  • path {string} Either absolute path, relative path from CWD, or Twig Namespace path like @bolt-components-foo/foo.schema.json.

Example

{{ validate_data_schema('@namesapce/foobar.schema.yml', _self) }}

console_log( data )

Outputs data to the browser's console log., (*3)

Parameters

  • data Any data you would like to log to the console from a twig template.

Example

{{ console_log(page.meta) }}

The Versions

15/03 2018
20/11 2017
10/11 2017
10/11 2017
09/11 2017

v0.1.1

0.1.1.0

  Sources   Download

MIT