Commit Graph
262 Commits
Author SHA1 Message Date
Justin Hileman 01d413de0d Merge branch 'hotfix/2.2.0' into dev
Conflicts:
	src/Mustache/Compiler.php
	src/Mustache/Engine.php
2013-03-25 09:12:36 -07:00
Justin Hileman c160134b6d Add a 'strict_callables' option to Mustache_Engine
Prevents treating array('ClassName', 'methodName') or array($instance, 'methodName') as section or interpolation callables. This helps protect against arbitrary code evaluation when user input is passed directly into the template.

This setting is recommended for PHP 5.3+, and all PHP 5.2 projects not using section or interpolation lambdas.

The default value is false to preserve backwards compatibility.

See #138
2013-03-23 10:54:13 -07:00
Justin Hileman ca44ef68f8 Move loader cascading into the loadPartial method.
This means the `partialsLoader` property is never set to the default loader, fixing things like `setPartials`, but template loading cascades as per the spec.

Add test coverage for partial cascading.
2013-03-12 16:03:58 -07:00
Matt DeClaire 32b747be5c fix test: a partialLoader should match the loader when neither are specified 2013-03-12 15:19:12 -07:00
Justin Hileman 12d6884b4b Improve test coverage for custom escapers and charsets. 2013-01-26 16:48:35 -08:00
Justin Hileman a777c587f2 Add resolveValue method to base Template.
DRYs up compiled class output a bit and makes things FASTER!

Speeds up value resolution by 33% for primitives, 25% for methods and properties, and 10% for lambdas.
2013-01-26 16:19:06 -08:00
Justin Hileman cf76a4b8f9 Remove unused escape param from renderInternal 2013-01-26 14:49:14 -08:00
Justin Hileman e5bc8d5edf Add a CascadingLoader implementation. 2013-01-21 10:26:12 -08:00
Justin Hileman b22d15a759 Add an inline template loader.
This loader is awesome for micro-frameworks such as Silex :)
2013-01-21 10:03:57 -08:00
Justin Hileman 8b02366a3f Add test coverage for new exception types. 2013-01-20 10:50:00 -08:00
Justin Hileman 0436c59477 Improve Mustache exception types, catchability.
* Subclass common exception types (runtime, logic, invalid argument).
 * Add new "unknown x" exceptions for filters, helpers and templates.
 * Make all Mustache exceptions implement Mustache_Exception interface… Gotta catch 'em all!
2013-01-20 10:35:55 -08:00
Justin Hileman 1515f5126b Update logger to implement accepted PSR log spec
Add tests!
2013-01-11 22:48:43 -08:00
Justin Hileman 1560863c49 Failing test for empty-string filesystem loader extension.
See #123
2012-11-28 12:58:20 -08:00
Justin Hileman 2872dd5048 Another non-callable test case for good measure 2012-10-01 14:51:15 -07:00
Justin Hileman fc453b5d01 Better filters implementation:
* Throw UnexpectedValueException when unknown
   filter is found.
 * More optimized compiler code.
 * Falsey initial values will still be fed through
   the pipe.
2012-10-01 14:51:15 -07:00
Justin Hileman 1cf44d5de9 First value in the pipe should be interpolated first. 2012-10-01 14:51:15 -07:00
Justin Hileman a64a6f82ee Handle broken pipes 2012-10-01 14:51:15 -07:00
Justin Hileman d209d1aea9 Implement {{% FILTERS }} pragma. 2012-10-01 14:51:14 -07:00
Justin Hileman 277288137b Coding standards fixes. 2012-08-02 10:36:07 -07:00
Justin Hileman cc7d164a42 Coding standards fix. 2012-08-02 10:32:35 -07:00
Justin Hileman 510f6cafd1 Merge branch 'dev' into feature/lambda-helper 2012-08-02 10:03:30 -07:00
Justin Hileman 83cf3158ae Context::find Failing test
Closures don't like it when you touch their properties.
2012-08-01 23:08:17 -07:00
Justin Hileman 169e6e0a1f Fix whitespace in a few test files (PSR-2) 2012-07-27 17:58:55 -07:00
Justin Hileman 52c7ccf1b9 Pass a helper to section lambdas 2012-07-23 11:56:23 -07:00
Justin Hileman 2448992cc8 Update to proposed PSR-1 coding standard.
* 4 space (no tab) indent
 * K&R-style braces
2012-05-01 22:03:39 -07:00
Justin Hileman be5cfb3e9e Rename Mustache_Mustache to Mustache_Engine.
Because the former was just too absurd to keep typing.
2012-05-01 21:30:22 -07:00
Justin Hileman 1ffd7c1a8f Remove some more slashes for 5.2. 2012-05-01 14:25:02 -07:00
Justin Hileman 0135107769 Only PHP >= 5.3.0 can call templates directly. 2012-05-01 14:20:26 -07:00
Justin Hileman a47289607d Templates are only callable in 5.3+ 2012-05-01 14:08:14 -07:00
Justin Hileman d1912038f3 Segregate 5.3+ tests, exclude them from phpunit config. 2012-05-01 14:03:11 -07:00
Justin Hileman 9316775ccb Fix test failures in PHP 5.2.x 2012-05-01 10:19:03 -07:00
Justin Hileman 2328615772 Change text tokens to proper tokens (instead of strings) 2012-03-26 19:34:55 -07:00
Justin Hileman 1430b27f86 Move examples into the test fixtures. 2012-03-26 19:05:08 -07:00
Justin Hileman 99a5e9b14a Per the spec, missing partials should be treated as an empty string. 2012-03-24 20:45:39 -07:00
scribu 550da21455 replace __DIR__ with dirname(__FILE__) 2012-03-17 23:05:52 -07:00
Justin Hileman bec9ce8448 Add support for PHP 5.2.x 2012-03-17 23:05:52 -07:00
Justin Hileman 23a4bb04f2 Add custom variable escapers.
cf. #86

 * Add `escape` Mustache constructor option. Expects something callable.
 * Update Compiler to either inline `htmlspecialchars` (old way) or a call to the custom escaper callback.
 * Update Compiler to statically compile charset.
 * Update template classname to account for charset and custom compilers.
2012-03-14 20:07:16 -07:00
Justin Hileman ba75d746e1 Add Helper implementation. 2012-03-14 17:49:38 -07:00
Justin Hileman 50b3594458 Fix failing partials example.
Only prepend $indent to the first output on a new line.
2012-03-14 17:41:38 -07:00
Justin Hileman 367013f01c 2x faster. Who needs a Buffer instance, anyway? 2012-03-14 00:00:00 -07:00
Justin Hileman 9a334cddf0 Inline isCallable and isTruthy into compiled templates
~3-5% performance gain.
2012-03-13 20:45:26 -07:00
Justin Hileman a196ac8dab Clean up Tokenizer constants.
Remove a bunch of hardcoded strings from everywhere.
2012-03-05 14:25:32 -08:00
Justin Hileman 36e7247b1e Add a shortcut Mustache::render invocation.
Consistent with the old 1.x API.
2012-03-04 21:42:20 -08:00
Justin Hileman 4e733287cc Clean up vendor libraries. 2012-03-01 07:27:11 -08:00
Justin Hileman eed4400afb Add file header docblocks. 2012-03-01 07:17:13 -08:00
Justin Hileman 01312d3e98 Add a Mustache Autoloader implementation. 2012-03-01 07:09:36 -08:00
Justin Hileman 5c4fcd0c9a Coding standard cleanup. 2012-03-01 05:26:32 -08:00
Justin Hileman 0034bf657b Add test coverage for Mustache.php 2.0
Update legacy tests for new codebase.
2012-02-29 19:12:22 -08:00
Justin Hileman 8710e4b8a4 Rearrange legacy tests. 2012-02-29 18:54:05 -08:00
Justin Hileman d2136d91b3 Initial Mustache.php 2.0 commit. 2012-02-29 18:01:57 -08:00