Skip to content

Commit

Permalink
Merge branch '1.0' into 1
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 13, 2025
2 parents 4276205 + 2fa16c3 commit 5f26995
Show file tree
Hide file tree
Showing 2 changed files with 1,699 additions and 2,148 deletions.
87 changes: 1 addition & 86 deletions src/SSTemplateParser.peg
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class SSTemplateParser extends Parser implements TemplateParser
# primary matcher, and is used by all enclosing blocks, as well as a base for the top level.
# Any new template elements need to be included in this list, if they are to work.

Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | Include | ClosedBlock |
OpenBlock | MalformedBlock | MalformedBracketInjection | Injection | Text)+
*/
function Template_STR(&$res, $sub)
Expand Down Expand Up @@ -792,91 +792,6 @@ class SSTemplateParser extends Parser implements TemplateParser

/*!*

# Deprecated old-style i18n _t and sprintf(_t block tags. We support a slightly more flexible version than we used
# to, but just because it's easier to do so. It's strongly recommended to use the new syntax

# This is the core used by both syntaxes, without the block start & end tags

OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")?

# whitespace with a newline
N: / [\s\n]* /
*/
function OldTPart__construct(&$res)
{
$res['php'] = "_t(";
}

function OldTPart_QuotedString(&$res, $sub)
{
$entity = $sub['String']['text'];
if (strpos($entity ?? '', '.') === false) {
$res['php'] .= "\$scope->getOutputValue('I18NNamespace').'.$entity'";
} else {
$res['php'] .= "'$entity'";
}
}

function OldTPart_CallArguments(&$res, $sub)
{
$res['php'] .= ',' . $sub['php'];
}

function OldTPart__finalise(&$res)
{
$res['php'] .= ')';
}

/*!*

# This is the old <% _t() %> tag

OldTTag: "<%" < OldTPart > "%>"

*/
function OldTTag_OldTPart(&$res, $sub)
{
$res['php'] = $sub['php'];
}

/*!*

# This is the old <% sprintf(_t()) %> tag

OldSprintfTag: "<%" < "sprintf" < "(" < OldTPart < "," < CallArguments > ")" > "%>"

*/
function OldSprintfTag__construct(&$res)
{
$res['php'] = "sprintf(";
}

function OldSprintfTag_OldTPart(&$res, $sub)
{
$res['php'] .= $sub['php'];
}

function OldSprintfTag_CallArguments(&$res, $sub)
{
$res['php'] .= ',' . $sub['php'] . ')';
}

/*!*

# This matches either the old style sprintf(_t()) or _t() tags. As well as including the output portion of the
# php, this rule combines all the old i18n stuff into a single match rule to make it easy to not support these
# tags later

OldI18NTag: OldSprintfTag | OldTTag

*/
function OldI18NTag_STR(&$res, $sub)
{
$res['php'] = '$val .= ' . $sub['php'] . ';';
}

/*!*

# An argument that can be passed through to an included template

NamedArgument: Name:Word "=" Value:Argument
Expand Down
Loading

0 comments on commit 5f26995

Please sign in to comment.