Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Eigenen Literal Tag erstellen

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 149
Location: Germany

PostPosted: Thu Feb 08, 2018 6:07 pm    Post subject: Eigenen Literal Tag erstellen Reply with quote

Hallo zusammen,

wie kann ich einen eigene Block-Funktion erstellen die dann aber so "behandelt" wird wie der Literal Tag.

Was will ich tun?

Ich möchte einen scriptblock-Tag erstellen. Alles was dort eingefügt wird, wird mit einem

Code:
<script>//Inhalt des {scriptblock}</script>


ummantelt. Jedoch ist es so, dass ich nicht einfach dort den javascript code einfügen kann, da mir dann ein compiler fehler geschmissen wird, weil eben

Code:
{
und
Code:
{


vorkommt.


Weiß jemand wie ich es umgehen kann?
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1189

PostPosted: Thu Feb 08, 2018 10:29 pm    Post subject: Reply with quote

I'm not quite sure, what exactly are you trying to do.
Can you please elaborate, what does not work for you with {literal} tag?
Back to top
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 149
Location: Germany

PostPosted: Fri Feb 09, 2018 6:23 am    Post subject: Reply with quote

I want create a custom block function who is working like the literal tag, so that I can insert { and } between that block element.

Example:

Code:

{mycustomliteral}
var i = {foo:'bar'};
{/mycustomliteral}


But, when I create a custom block function the content will be compiled before so that I get an error. The reason is this code part:

Code:
{foo:'bar'}
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1189

PostPosted: Fri Feb 09, 2018 5:16 pm    Post subject: Reply with quote

Why you can't use an already existing block?
Back to top
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 149
Location: Germany

PostPosted: Fri Feb 09, 2018 7:39 pm    Post subject: Reply with quote

Because I wrap it internal with a script tag automatically and I can set the "appendToEnd" property, so that the content appends to end or rendered directly on the place where it insert/added
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP