NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Smarty {literal} tag highlighting


Joined: 20 Jul 2009
Posts: 9
Reply with quote
There seems to be a bug in how the editor handles code entered between Smarty's {literal} {/literal} tags. It is displayed as non-smarty text even with dynamic highlighting disabled. HTML code outside of these tags displays with syntax highlighting, but within the tag it is shown as the italic gray (default). If you consider this a "feature," please consider adding a toggle. It was working fine in 5.5 but it now appears broken following a recent upgrade to 5.8.
View user's profileFind all posts by squ3lchSend private message


Joined: 09 Jul 2009
Posts: 13
Reply with quote
I think it may use whatever highlighting the {literal} tag possesses.

For example: if the {literal} tag is inside a <script type="text/javascript"> block, then all the code inside of it has javascript highlighting.

I haven't really tested this in many other situation, but with javascript to get highlighting, I put it inside the <script> tag. Same thing for styles.
View user's profileFind all posts by killermonkSend private message


Joined: 20 Jul 2009
Posts: 9
Reply with quote
Thanks for the info. I got the standard "working as intended" reply from my bug report email that I expected. I still think it should follow dynamic highlighting rules though.
View user's profileFind all posts by squ3lchSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8351
Reply with quote
"dynamic highlighting" is a different term. When turned on, it highlights only areas with the same language as under the cursor. In case of {literal}, it's still smarty area. The only difference of this area is that no smarty tags are recognized in it, except {/literal}.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 20 Jul 2009
Posts: 9
Reply with quote
That's great and all, but it's still annoying to try to edit 100+ lines of javascript inside {literal} tags without syntax highlighting. Surely I'm not the only one with that problem.
View user's profileFind all posts by squ3lchSend private message


Joined: 09 Jul 2009
Posts: 13
Reply with quote
If you are using it inside of a smarty.tpl and you have <script type="text/javascript"> around it, then put the literal tag inside the script block. This will cause the editor to move out of the smarty highlighting mode and into javascript mode. Once it is in javascript mode, it will (essentially) just ignore the {literal} tag (or treat it as a syntax error) and continue using javascript highlighting until it finds a </script> tag.

So to get javascript highlighting, do it like this:

<script type="text/javascript">
{literal}

... javascript ...

{/literal}
</script>
View user's profileFind all posts by killermonkSend private message
Smarty {literal} tag highlighting
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
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic