Created
July 15, 2016 15:44
-
-
Save knksmith57/1d3e07914fd6085ba286718b5f6c820b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "knksmith57/lnc-identity-call-stack-error", | |
"description": "example setup for reproducing LnC #235", | |
"authors": [ | |
{ | |
"name": "Kyle Smith", | |
"email": "[email protected]" | |
} | |
], | |
"require": { | |
"zordius/lightncandy": "v0.89" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_readme": [ | |
"This file locks the dependencies of your project to a known state", | |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | |
"This file is @generated automatically" | |
], | |
"hash": "920b6a4b9ea52bba83e42ff4d2a07739", | |
"content-hash": "3d8a57e817766d5aa06e8486b084d658", | |
"packages": [ | |
{ | |
"name": "zordius/lightncandy", | |
"version": "v0.89", | |
"source": { | |
"type": "git", | |
"url": "https://github.com/zordius/lightncandy.git", | |
"reference": "af1f9adec7bc684409cd2b01cbca02967edc14b4" | |
}, | |
"dist": { | |
"type": "zip", | |
"url": "https://api.github.com/repos/zordius/lightncandy/zipball/af1f9adec7bc684409cd2b01cbca02967edc14b4", | |
"reference": "af1f9adec7bc684409cd2b01cbca02967edc14b4", | |
"shasum": "" | |
}, | |
"require": { | |
"php": ">=5.3.0" | |
}, | |
"require-dev": { | |
"phpunit/phpunit": "4.0.17" | |
}, | |
"type": "library", | |
"autoload": { | |
"psr-4": { | |
"LightnCandy\\": "src" | |
} | |
}, | |
"notification-url": "https://packagist.org/downloads/", | |
"license": [ | |
"MIT" | |
], | |
"authors": [ | |
{ | |
"name": "Zordius Chen", | |
"email": "[email protected]" | |
} | |
], | |
"description": "An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ).", | |
"homepage": "https://github.com/zordius/lightncandy", | |
"keywords": [ | |
"handlebars", | |
"logicless", | |
"mustache", | |
"php", | |
"template" | |
], | |
"time": "2015-12-05 13:08:25" | |
} | |
], | |
"packages-dev": [], | |
"aliases": [], | |
"minimum-stability": "stable", | |
"stability-flags": [], | |
"prefer-stable": false, | |
"prefer-lowest": false, | |
"platform": [], | |
"platform-dev": [] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
error_reporting(E_ALL); | |
require_once('vendor/autoload.php'); | |
use LightnCandy\LightnCandy; | |
$template = '{{>(identity @root.foo.bar.baz)}}'; | |
$phpStr = LightnCandy::compile($template, [ | |
'flags' => 0 | |
| LightnCandy::FLAG_RENDER_DEBUG | |
| LightnCandy::FLAG_BESTPERFORMANCE | |
| LightnCandy::FLAG_ERROR_EXCEPTION | |
| LightnCandy::FLAG_RUNTIMEPARTIAL | |
| LightnCandy::FLAG_SPACECTL | |
| LightnCandy::FLAG_SPVARS | |
| LightnCandy::FLAG_HANDLEBARS, | |
'helpers' => [ | |
'identity' => '\HandlebarsHelpers::identity' | |
], | |
'partials' => [ | |
'myPartial' => 'hello, world' | |
] | |
]); | |
$output = eval('?>' . $phpStr); | |
echo $output([ | |
'foo' => [ | |
'bar' => [ | |
'baz' => 'myPartial' | |
] | |
] | |
]); | |
class HandlebarsHelpers | |
{ | |
public static function identity ($args) { | |
$argc = count($args); | |
if ($argc !== 1) { | |
throw new \RuntimeException('identity helper requires exactly one positional argument'); | |
} | |
return $args[0]; | |
} | |
} | |
Author
knksmith57
commented
Jul 15, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment