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

Support: looking a way to get smarty parse tree #364

Closed
glensc opened this issue May 12, 2017 · 12 comments
Closed

Support: looking a way to get smarty parse tree #364

glensc opened this issue May 12, 2017 · 12 comments

Comments

@glensc
Copy link
Contributor

glensc commented May 12, 2017

I'm looking a way to get tokens from smarty, something similar to
getTags(), but with other tokens as well like text nodes.

The intention is to write external parser to extract {t attrib="123" attr2='foo bar'}text here{/t} as tokens by smarty own parser, instead of using regexps on source template file.

Here's example how getTags is being used good way externally:
https://github.com/geekwright/Po/blob/v1.0.4/src/PoInitSmarty.php#L189-L218

however that solution does not apply to me because i need the TEXT element from between t and tclose notes.

@AnrDaemon
Copy link
Contributor

I don't quite understand, why YOU want to parse Smarty template?
Why don't you just write a Smarty plugin and Smarty will send everytihing you you ready and parsed?

@glensc
Copy link
Contributor Author

glensc commented Jun 8, 2017

see related links in this issue. i need {t opts=111}...{/t} not render actual template.

can you provide example how to get same result with plugin? what is plugin anyway? any docs?

@AnrDaemon
Copy link
Contributor

Please read http://xyproblem.info/ before answering my question.
Now, the question: WHY do you want to do this?
What would be the end result for you?

@glensc
Copy link
Contributor Author

glensc commented Jun 9, 2017

looks like you never visited any links given. sad.

smarty-gettext has tool named tsmarty2c (manual: tsmarty2c.1), which uses regexps to scan templates for the translations. there are several bugs and features requested (#1, #15, #20) which i tried to solve with some code refactoring but decided that that i'll be doing it wrong inventing all moving parts myself and rather use existing components.

so a new project was porn: smarty-gettext/tsmarty2c, which attempts to do this properly, using parser not regexp. initial 0.1.0 release target can be seen from the ticket: #1

@AnrDaemon
Copy link
Contributor

Why should I visit any links? I asked YOU, what YOU want to do with this information.

@glensc
Copy link
Contributor Author

glensc commented Jun 11, 2017

indeed, you shouldn't do anything, you're just trolling me, not helping anybody. the links provide extra information what you may be searching for. for the implementation i provided enough information in initial issue description.

@AnrDaemon
Copy link
Contributor

AnrDaemon commented Jun 13, 2017

I'm searching for information I asked you to provide.
If you are unable to state clearly, what you want to get done, you most likely don't need it and just wishfully thinking.

@glensc
Copy link
Contributor Author

glensc commented Jun 13, 2017

what i want is described in initial description: #364 (comment)

if you're unable to help (you are not maintainer!), just stop posting there. thank you.

@AnrDaemon
Copy link
Contributor

That answers "how" not "what". See http://xyproblem.info/

@wisskid
Copy link
Member

wisskid commented Feb 6, 2020

Hi @glensc, I see what you were trying to do here and it seems you've already been able to do so on your own. Good job. I don't see a clear use case here for Smarty other than what you have been doing, so closing this issue now.

@wisskid wisskid closed this as completed Feb 6, 2020
@glensc
Copy link
Contributor Author

glensc commented Feb 7, 2020

@wisskid, it's a hackish one, mostly works, but unfortunately, it doesn't solve all scenarios needed, i.e when template uses variable assignments and that result inside {t}{/t} tags:

@glensc
Copy link
Contributor Author

glensc commented Jul 9, 2020

@wisskid sadly using internals like that caused breakage since 3.1.35:

The bisected commit to the breakage is 19ef834

belonging to #582

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

No branches or pull requests

3 participants