2017 © Pedro Peláez
 

template moredraw

Handlebars two-side wrapper (js/php) - Same template anywhere with reactive update

image

fe3dback/moredraw

Handlebars two-side wrapper (js/php) - Same template anywhere with reactive update

  • Tuesday, April 11, 2017
  • by fe3dback
  • Repository
  • 1 Watchers
  • 1 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

DEPRECATED

Please see v2 instead: https://github.com/fe3dback/kx-draw, (*1)

Build Status Coverage Status, (*2)

MoreDraw

Smart handlebars template with two-side render (php/js) with just one template and reactive data update. Based on zordius/lightncandy && handlebars parser, (*3)

Require (install)

  • composer (for install)
  • php7 (at least)
  • http://handlebarsjs.com/ (optional, for js render only)

Install PHP Side

install deps:, (*4)

$ cd /your-project/
$ composer require fe3dback/moredraw

in project init (config, etc..) (before we use template render), (*5)

require_once 'vendor/autoload.php';

$moreDraw = new NeoHandlebars\MoreDraw();
$moreDraw->init([
  'templates_dir' => __DIR__ . '/templates', // where templates will be
  'cache_dir' => __DIR__ . '/tmp/cache' // where cache will be
]);

Install JS Side (optional, only for js use)

Install handlebars parser (handlebars.min-latest.js) from this page: http://builds.handlebarsjs.com.s3.amazonaws.com/bucket-listing.html?sort=lastmod&sortdir=desc, (*6)

Or from official site: http://handlebarsjs.com/installation.html, (*7)

in site footer (place when you include js files), add js lib, (*8)







=$moreDraw->getAllJSTemplates()?>

Use

Use. Server Side

Create file examples/test.hbs in your templates folder. With some content like this: hello {{name}}!, (*9)

// _index is optional, only if we need provided data in js later
echo $moreDraw->render('examples/test', ['_index' => 'to_world', 'name' => 'world']); // Hello world!
echo $moreDraw->render('examples/test', ['_index' => 'to_universe', 'name' => 'universe']); // Hello universe!
Use. Client Side
let data = MoreDraw.getData('examples/test', 'to_world'); // {'name' => 'world'}
data.name = data.name + " & me";
let html = MoreDraw.render('examples/test', data); // Hello world & me!

The Versions

11/04 2017

dev-master

9999999-dev

Handlebars two-side wrapper (js/php) - Same template anywhere with reactive update

  Sources   Download

MIT

The Requires

 

The Development Requires

by HC

template php js handlebars logicless