Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested blocks parsing #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

nested blocks parsing #10

wants to merge 2 commits into from

Conversation

glensc
Copy link
Member

@glensc glensc commented Nov 12, 2017

smarty parses it, tsmarty2c does not:

{function name="reply_button" class="" title="" data=""}
{/function}

{reply_button title="{t}reply as email{/t}" class="reply_as_email"}

@glensc
Copy link
Member Author

glensc commented Nov 12, 2017

seems smarty relies here on implementation details. i.e fills php variable in place of {t}{/t}:

{function name="reply_button" class="" title="" data=""}{/function}
{reply_button title="{t}reply as email{/t}" class="reply_as_email"}

parsed into tokens:

array:7 [
  0 => SmartyGettext\Tokenizer\Token\Tag {#45
    +line: 1
    +name: "function"
    +arguments: array:4 [
      0 => array:1 [
        "name" => ""reply_button""
      ]
      1 => array:1 [
        "class" => "''"
      ]
      2 => array:1 [
        "title" => "''"
      ]
      3 => array:1 [
        "data" => "''"
      ]
    ]
  }
  1 => SmartyGettext\Tokenizer\Token\Tag {#44
    +line: 1
    +name: "functionclose"
    +arguments: []
  }
  2 => SmartyGettext\Tokenizer\Token\Text {#49
    +line: 2
    +text: "\n"
  }
  3 => SmartyGettext\Tokenizer\Token\Tag {#55
    +line: 2
    +name: "t"
    +arguments: []
  }
  4 => SmartyGettext\Tokenizer\Token\Tag {#61
    +line: 2
    +name: "tclose"
    +arguments: []
  }
  5 => SmartyGettext\Tokenizer\Token\Tag {#52
    +line: 2
    +name: "reply_button"
    +arguments: array:2 [
      0 => array:1 [
        "title" => "$_prefixVariable1"
      ]
      1 => array:1 [
        "class" => ""reply_as_email""
      ]
    ]
  }
  6 => SmartyGettext\Tokenizer\Token\Text {#58
    +line: 2
    +text: "\n"
  }
]

https://github.com/smarty-php/smarty/blob/v3.1.31/libs/sysplugins/smarty_internal_templatecompilerbase.php#L1335

@glensc glensc force-pushed the translation_in_argument branch 3 times, most recently from 395b271 to 1363e4b Compare November 12, 2017 03:29
@glensc
Copy link
Member Author

glensc commented Nov 12, 2017

that above template cache:

<?php ob_start();
$_smarty_tpl->smarty->_cache['_tag_stack'][] = array('t', array());
$_block_repeat=true;
echo smarty_block_t(array(), null, $_smarty_tpl, $_block_repeat);
while ($_block_repeat) {
ob_start();
echo "reply as email";
$_block_repeat=false;
echo smarty_block_t(array(), ob_get_clean(), $_smarty_tpl, $_block_repeat);
}
array_pop($_smarty_tpl->smarty->_cache['_tag_stack']);

$_prefixVariable1=ob_get_clean();
$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction($_smarty_tpl, 'reply_button', array('title'=>$_prefixVariable1,'c....

@glensc
Copy link
Member Author

glensc commented Jul 4, 2019

this problem seems unsolveable unless someone implements Smarty parser themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant