MyBB Community Forums

Full Version: Function for rendering templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Just curious, is this slated for 1.8.0 or 1.8.1? I'd put it in to 1.8.0 due to the drastic changes it entails and to make it available to plugin developers from day 1 but I may be a little biased Toungue
Getting rid of eval() entirely would be a drastic change; this is just semantics. Wink

Any reason you changed the order of parameters? In your first post in this thread it was render($var, $template) which felt more intuitive to me than the other way around. Some of the variable names make it confusing which is the variable and which the template name.

Still not sure if it shouldn't include $ and = anyway, which would look like this:

eval($template->render('$var=', 'thetemplate'));

That'd make it obvious what is happening (variable assignment), even to someone unfamiliar with the render function.
I chose the way I did because I figured since the object deals with templates, and the function deals with templates, that the template parameter should be the first one. I do agree that having the variable first would be a little better but that's just a sed script to change so I have no problem redoing it.

As far as special characters the whole point was to try and get rid of them. Including the '$' would make it easy for someone to forget it needs to be quoted, or do the wrong thing if they use double quotes instead of single quotes, or requires escaping. Including both that and the '=' or '.=' and the function starts getting into "pointless" territory.

I did come across a couple of instances where some special characters were needed anyway, but that was for assigning to array slots (i.e. passing "arr['key']" which is annoying). I also came across a couple of instances where a template was being rendered in an odd sequence (doing a grep on 'templates->get' will find it). I left that one alone because I wasn't 100% on what was happening and didn't want to break something.
How about a return statement then? MyBB does not currently use eval('return "string";') but it should work and then it would turn into this:

$var = eval($templates->render('template'));

Just throwing ideas around.
That looks like a much better approach to me frostschutz,.
Indeed, I like that a lot!

Alright, I'll go through and redo it.

Pull request 3: The Empulling
https://github.com/mybb/mybb/pull/1332

Dang, off by 4...

Alright, I'm sorry about all the mess with redoing pull requests repeatedly, but due to the way I did things it was literally easier to just start over from feature than try to get things working with the other one. I blame sed for being a write-once scripting tool Toungue

Also it's a little cleaner without the unfixing commit for the line endings.
Pages: 1 2