Skip to content

Commit

Permalink
add support for <%- tags
Browse files Browse the repository at this point in the history
this indicates that leading whitespace should be ignored
  • Loading branch information
AD7six committed Nov 14, 2014
1 parent e48ab63 commit 5a04c5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/View/BakeView.php
Expand Up @@ -33,11 +33,12 @@ class BakeView extends View {
*
* replacements are applied in order on the template contents before the template is evaluated
* In order these:
* swallow leading whitespace for standard tempalte open tags
* Add an extra newline to short-echo tags, to counter act php automatically removing a newline
* Replace remaining short echo tags with php short echo tags
* Replace open tags with php open tags
* Replace close tags with php close tags
* swallow leading whitespace for <%- tags
* swallow trailing whitespace for -%> tags
* Add an extra newline to <%=, to counteract php automatically removing a newline
* Replace remaining <=% with php short echo tags
* Replace <% with php open tags
* Replace %> with php close tags
*
* @var array
*/
Expand All @@ -48,7 +49,8 @@ class BakeView extends View {
' ?>' => " CakePHPBakePhpCloseTag>"
],
'replacements' => [
'/\n[ \t]+<% /' => "\n<% ",
'/\n[ \t]+<%- /' => "\n<% ",
'/-%>[ \t]+\n/' => "%>\n",
'/<%=(.*)\%>\n(.)/' => "<%=$1%>\n\n$2",
'<%=' => '<?=',
'<%' => '<?php',
Expand Down
Expand Up @@ -7,7 +7,7 @@
<% endforeach; %>

This should make no difference:
<% foreach([1,2,3] as $number): %>
<%- foreach([1,2,3] as $number): %>
<%= $number %>
<% endforeach; %>
<%- endforeach; %>
And the previous line should not have leading whitespace.

0 comments on commit 5a04c5e

Please sign in to comment.