empty placeholder in template

142 views
Skip to first unread message

Walter456

unread,
Aug 1, 2012, 5:51:29 AM8/1/12
to rai...@googlegroups.com
Hello !

I looking for a way to define placeholders with an empty value.
For example:
---------------------
...

<form>
    <input name="firstname" value"{firstname}">
    <input name="firstname" value"{lastname}">
</form>

...

---------------------
When no content for the variable 'firstname' or 'lastname' php get a error notice.
Is there a way to set a flag to parse the template

-----------------------
<form>
    <input name="firstname" value"&nbsp;">
    <input name="firstname" value"&nbsp;">
</form>
-----------------------

Sorry for my bad english.

Your sincerly

Stephan


Federico Ulfo

unread,
Aug 1, 2012, 7:52:22 AM8/1/12
to rai...@googlegroups.com
Hi Stephan,
we talk about this problem long ago, we thought about introducing a new configuration "empty_var" so that you won't get a warning if a variable is used even if empty.

By default I think is correct that RainTPL throw this error, because if you have a typo or if you forget on the server side to assign a variable, you get an error. I have to verify how hard is to implement this feature, if is not too hard I will implement it.

Federico

Stephan

unread,
Aug 2, 2012, 3:25:31 AM8/2/12
to rai...@googlegroups.com

Hello Federico!

Thanks for the information.
Today I must find time to test this setting.
I have an idea.

Can i see with {$template_info} unused variables?

 

Yours sincerely,

Stephan


Federico Ulfo <rainel...@gmail.com> hat am 1. August 2012 um 13:52 geschrieben:

Federico Ulfo

unread,
Aug 2, 2012, 10:12:12 AM8/2/12
to rai...@googlegroups.com
Hi Stephan,
yes {$template_info} purpose is to show you what variables you can use.

Federico

Arief

unread,
Feb 28, 2014, 10:31:56 AM2/28/14
to rai...@googlegroups.com
Hi Rain,

How's this feature going on?

For development, it's ok when there's unassigned variable and show php error base $varname not found, but in production it would be nice to just print the raintpl var.
For example if $username not assigned then it simply prints {$username}, so it can eliminate blank screen of death as php display error set to log file on production.

Is empty_var available in config now?

Thanks. 

Federico Ulfo

unread,
Mar 3, 2014, 10:02:12 PM3/3/14
to raintpl
Hi, I don't think I will implement this feature any time soon, too much busy with new projects.

Thanks


--
---
You received this message because you are subscribed to the Google Groups "raintpl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raintpl+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Arief

unread,
Mar 21, 2014, 10:58:52 PM3/21/14
to rai...@googlegroups.com
I made a small changes to file Parser.php on line 580. 

// if is an assignment it doesn't add echo
if ($echo) {
 $html = "echo (isset($html)? $html : '{" . $html . "}');";
}

When var $username not assigned it will now display {$username}. 

That would be easier then if we can introduce empty_var from config by simply replacing '{" . $html . "}' i guess.

Thanks.

Arief

unread,
Mar 24, 2014, 10:33:55 PM3/24/14
to rai...@googlegroups.com
My Previous code does not work if a variable has modifier, so there should be a check for char "(" indicating it's a function modifier. Here's the revision :

// if is an assignment it doesn't add echo
if ($echo) {
// Ignore if $html contains '('. It means it has modifier replace.
if (strpos($html, '(') === FALSE) {
$html = "echo (isset($html)? $html : '{" . $html . "}');";
} else {
$html = "echo " . $html;
Reply all
Reply to author
Forward
0 new messages