PartialLambdaIndentTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2010-2014 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * @group lambdas
  12. * @group functional
  13. */
  14. class Mustache_Test_FiveThree_Functional_PartialLambdaIndentTest extends PHPUnit_Framework_TestCase
  15. {
  16. public function testLambdasInsidePartialsAreIndentedProperly()
  17. {
  18. $src = <<<EOS
  19. <fieldset>
  20. {{> input }}
  21. </fieldset>
  22. EOS;
  23. $partial = <<<EOS
  24. <input placeholder="{{# _t }}Enter your name{{/ _t }}">
  25. EOS;
  26. $expected = <<<EOS
  27. <fieldset>
  28. <input placeholder="ENTER YOUR NAME">
  29. </fieldset>
  30. EOS;
  31. $m = new Mustache_Engine(array(
  32. 'partials' => array('input' => $partial)
  33. ));
  34. $tpl = $m->loadTemplate($src);
  35. $data = new Mustache_Test_FiveThree_Functional_ClassWithLambda();
  36. $this->assertEquals($expected, $tpl->render($data));
  37. }
  38. }
  39. class Mustache_Test_FiveThree_Functional_ClassWithLambda
  40. {
  41. public function _t()
  42. {
  43. return function ($val) {
  44. return strtoupper($val);
  45. };
  46. }
  47. }