Using boolean data in CIs template Parser |
[eluser]Unknown[/eluser]
Hi there I made a small modification to the template parser class to make it possible to use boolean data to control {tag}{/tag} pairs like: Code: {itemspresent} It isn't thoroughly tested and may have a speed penalty when working with boolean data not intended for this use case, but it works quite well for me and was the one feature I needed to allow me to use the build-in template parser for all my views. I have attached the full patched version as well as the patch file to the 1.7.2 version.
[eluser]Phil Sturgeon[/eluser]
Someone did this about a year ago with this same syntax. Someone else did something similar even more recently. People really should search before they write code, just to make sure they arent duplicating efforts.
[eluser]Unknown[/eluser]
@wiredesignz Glad you like it ![]() @phil Actually I was just experimenting with CI and Template library, since I just started doing php again. I learned a lot about CI on the way and as I came to the point where I needed this feature, the modification took me about half an hour... Also the code you linked is way to generic for my taste. I don't want to have logic in my templates. @codeigniter team Feel free to include this in the core codebase ;-)
[eluser]Phil Sturgeon[/eluser]
Good man. Jumping into the core is the best way to learn not only how CodeIgniter works, but will teach you some great methodologies and clean syntax. The one I linked to was a bit dodgy, the one I mentioned first was however identical. That said if I cant find it that explains why you didn't either. :-p |
Welcome Guest, Not a member yet? Register Sign In |