Gossamer Forum
Home : Products : Gossamer Links : Discussions :

[Suggestion] Reuse DB connection in template tags

Quote Reply
[Suggestion] Reuse DB connection in template tags
Alex, GT staff,

1) Would be fine to be able to reuse DB connection in template tags.
I mean to be able to use $DB object in template tags. Even more would be useful to be able to use any object, like $DB, $CFG, $IN, $USER, etc.

Yes, I know they can be used in a global, but why to create a global for every small one-liner task?
This template parser improvement would help to avoid some short globals, by using object based function calls right in the template tags.

If $DB object would be possible to use, then we could do such function calling template tags:
Code:
<%$DB->form_display("Title")%>

Of course GT::Template parser would require modification to identify "$var->function()" style as function call.
I was thinking about the security risks, in the case we allow usage of object variables in the template tags, and I think there is not higher risk, than allowing using globals in templates.


2) Another suggestion could be to allow one-liner perl codes within the template tags such way:
Code:
<%{ one-liner perl code }%>
or
<%sub { one-liner perl code }%>
Identification could be not a difficult task in the template parser.
Should be executed as Code if: {.+} and sub\s+{.+}

Let me know, what do you think about these suggestions.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Subject Author Views Date
Thread [Suggestion] Reuse DB connection in template tags webmaster33 6453 Jan 22, 2003, 7:28 AM
Thread Re: [webmaster33] [Suggestion] Reuse DB connection in template tags
Paul 6296 Jan 22, 2003, 7:32 AM
Thread Re: [Paul] [Suggestion] Reuse DB connection in template tags
webmaster33 6269 Jan 22, 2003, 8:26 AM
Thread Re: [webmaster33] [Suggestion] Reuse DB connection in template tags
Paul 6288 Jan 22, 2003, 8:32 AM
Post Re: [Paul] [Suggestion] Reuse DB connection in template tags
webmaster33 6247 Jan 22, 2003, 8:53 AM
Thread Re: [webmaster33] [Suggestion] Reuse DB connection in template tags
Alex 6220 Jan 22, 2003, 11:56 AM
Post Re: [Alex] [Suggestion] Reuse DB connection in template tags
Alex 6240 Jan 22, 2003, 11:57 AM
Thread Re: [Alex] [Suggestion] Using object variables & methods in template tags
webmaster33 6213 Jan 22, 2003, 1:56 PM
Thread Re: [webmaster33] [Suggestion] Using object variables & methods in template tags
ridesworld 6202 Jan 22, 2003, 2:11 PM
Thread Re: [ridesworld] [Suggestion] Using object variables & methods in template tags
webmaster33 6179 Jan 22, 2003, 2:26 PM
Thread Re: [webmaster33] [Suggestion] Using object variables & methods in template tags
ridesworld 6154 Jan 23, 2003, 5:59 AM
Post Re: [ridesworld] [Suggestion] Using object variables & methods in template tags
Paul 6157 Jan 23, 2003, 6:03 AM
Thread Re: [ridesworld] [Suggestion] Using object variables & methods in template tags
webmaster33 6175 Jan 23, 2003, 6:36 AM
Thread Re: [webmaster33] [Suggestion] Using object variables & methods in template tags
ridesworld 6171 Jan 24, 2003, 12:19 AM
Post Re: [ridesworld] [Suggestion] Using object variables & methods in template tags
webmaster33 6139 Jan 24, 2003, 4:00 AM
Thread Re: [Alex] [Suggestion] Reuse DB connection in template tags
pugdog 6135 Jan 30, 2003, 5:56 AM
Post Re: [pugdog] [Suggestion] Reuse DB connection in template tags
webmaster33 6141 Jan 30, 2003, 6:19 AM