Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

wellcometrust/tpl-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tpl-php

CircleCI

Renderer for Drupal 7 .tpl.php files for use with pattern libraries.

Installation

npm install tpl-php

Dependencies

  • Node 7+
  • PHP 5+

Usage

Your template:

<h1>Good morning, <?php print $variables['name']; ?></h1>

In node:

const tpl = require('tpl-php');

tpl('my-template.tpl.php', { name: 'Alasdair' })
.then(rendered => console.log(rendered)); // <h1>Good morning, Alasdair</h1>

// if the template executes with errors, you can toggle whether they're shown in the output or not
tpl('my-template.tpl.php', { name: 'Alasdair' }, { showErrors: true });

Development

  • run tests with npm test
  • tests are located in the spec directory, and are based on jasmine.