Closed hardfire closed 11 years ago
There's nothing firm in mind at the moment. The thought that's been in the back of my head, though, is that we'll likely need to create our own that takes the place of the parser that already exists. This would work with the existing template library. Here's my (small) wishlist:
So, that's what's been tickling the back of my mind for a while, though we've never set anything firm. If you wanted to work on something like that, it would be awesome.
Hey yeah! This seems really impressive, especially the module interface, would just make life easier. I'd love to work on something like this, just a push in the right direction would help. Let me see how things are done most efficiently though..
Mostly we might have to set the template engine something like
Template::engine('engineName');
Then eventually, the template would load the proper engine and do the magic :)
I know that in PyroCMS they had Dan Horrigan write up a nice parser that they use for their template lib. Don't recall the specifics of their implementation or their licensing at the moment, but it should provide the basics for writing a new parser.
Aha! now i see where you get the module idea from. Pyro seems pretty impressive, looking at it.
And here's Dan's Lex library, which is what Pyro uses:
Currently, how do we call a module method from a template ?
Currently everything like that would happen through HMVC, so it would be something like:
<?php echo modules::run('module/controller/method', $params, $...); ?>
See their wiki for more info: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
Lonnie Ezell http://cibonfire.com - Kickstart your CodeIgniter app development http://TheNextRead.com - Serialized Fiction for the entrepreneurial author http://LonnieEzell.com - Web Mechanic, Fantasy Author, Musician
On Fri, Aug 24, 2012 at 10:21 AM, Avinash Kundaliya < notifications@github.com> wrote:
Currently, how do we call a module method from a template ?
— Reply to this email directly or view it on GitHubhttps://github.com/ci-bonfire/Bonfire/issues/549#issuecomment-8004481.
Inside of a Controller you can use
$this->load->module('module/controller');
$this->module->method();
Inside a view would be like Lonnie stated above.
Back on topic, Has anyone tried SImpleTags for a templating library?
Have not tried SimpleTags Did try blade templating library used in laravel and it is pretty elegant. So is twig. :)
I haven't tried it yet but it seems pretty Simple and better then the stock parser, which btw causes issues with our Template library
Ok, i have done some progress here. i created a parser, that calls Dan's lex library, pretty similar to what has been done in pyrocms.. (learned a lot there)
things are working and we can also call modules like {mod:user:list limit="10" offset="10"} , though the arguments name are useless, they are passed squentially to the method.
Only issue right now is when the module is also using the parser it goes into an infinite loop... will push the code as soon as i fix it or i think i need some help, whichever comes earlier :)
I ran into some issues with the parser and the template engine going into a loop and dieing, I pushed a fix yesterday for the default parser yesterday
This one right? https://github.com/ci-bonfire/Bonfire/issues/547 . will check soon!
ok, here is my parser class https://gist.github.com/3496437 .. most of it is pretty obvious. the issue here is that when i have a view like
{{ module2:method }}
and the module2 method also calls the parser, the parser calls the view for the original module and not module2 It is mostly because when the parser calls
$CI->load->view ...
It is in the context of the original module and not module2. Any Suggestions ?
@svizion somehow after this fix, the template is working but $data
is not being passed to the parser, its null ... looking into that right now ..
Yikes dangit! I think I know why, just not quite sure the fix to it yet, I'll take a look into it tonight, I actually found another bug in bonfire I've been lookin at today that's been annoying the hell outta me
Ok! good news. Things are working .. This is the view that i have used as a test for now ..
<h2>Hello {{ name }}</h2>
{{ news:index name='Don' }}
{{ news:awesome }}
<h2>Hello {{ name }}</h2>
<ul>
{{ posts }}
<li> {{ title }} - {{ id }} </li>
{{ /posts }}
</ul>
<ul>
{{ news:latest }}
<li> {{ date }} - {{ name }} - {{ id }} </li>
{{ /news:latest }}
</ul>
and i must tell it WORKS! :) I'll do some more tests and then push it asap.
That's awesome. Thanks so much! Sounds like a great addition.
We are getting ready for a push on the 0.6 branch to official, so this might get pushed off for the 0.7 release, but unsure currently.
I made a push in a (branch) [https://github.com/hardfire/Bonfire/tree/templateEngine] on my forked repository. Please have a look and let me know of the issues, if any comes up.
Did you get it to parse more then just a single view file or are we still stuck at that issue?
Ok, for that i am thinking of creating a template function for module methods that would work as widgets as such, Right now i have been loading them as simple views.
One more update. now we can call libraries too ... so this would work.
{{ Assets:image path='assets/images/image.jpg' }}
OK, I found this package https://gist.github.com/3802666 and works for me... thank you very much to dhorrigan, hardfire and svizion his library is awesome...
Hello, just one more thing. when I load the view from the themes folder is not parsed. I want my view from themes> mytheme> pages> view.php
When the view is loaded from modules> pages> views> view.php works well.
How to fix this?
This has been incorporated into the latest develop branch push, and it fixed the issue with themed views not being parsed, I believe. Please give it a thorough run through if you have the time. I haven't had a chance to do thorough testing on it yet, but I'm sure I will be as I write up some docs for it.
Are you still in the process of pushing that, or am I just looking in the wrong place for it?
Woops. Didn't notice the error that the push threw up. Fixing a merge conflict then it will be pushed momentarilly.
Okay, they should be there now. Sorry about that.
oh! wow, looks like the MY_Parser.php I once wrote is in use, awesome! I will also have a look and run some tests.
@hardfire Yup! Thanks so much for the code, it seems to work great so far! Let me know if you run into any issues, otherwise I will mark this one as closed.
are there any such plans, like maybe twig or something similar ? I think it helps a lot in the views.