rejetto forum
Software => HFS ~ HTTP File Server => Bug reports => Topic started by: raybob on July 14, 2012, 08:49:52 PM
-
I'm not sure if this was even intended to work, but it would be great if it could.
When using ^function|a|b|c , if the function is something like this {.set|function|{:{.load|test.tpl.}:}.} and test.tpl contains $1 $2 and $3, then the a,b,c parameters are not passed through into test.tpl. Test.tpl would be loaded with $1 $2 and $3 staying just like that and not expanding to the parameters a,b,c.
Maybe you could even make it so you could pass arguments into {.load.} directly like load|a|b|c :)
-
you can do it yourself by using {.replace.}
i don't know if you can still use $1 inside test.tpl
eventually you can use {1}
-
a,b,c parameters can be passed through into test.tpl. your problem is {.set|function|{:{.load|test.tpl.}:}.}
you have to macroquote all the text inside test.tpl
{: at the begin of file , :} at the end
and use the macro as it {.set|function|{.load|test.tpl.}.}
or {.set|function|{.dequote|{.load|test.tpl.}.}.} with the example
by example:
{:{.add to log| loading test.tpl.}
$1 $3 $2
{.add to log|$1 $3 $2.}
:}
then "load" is executed before "set" and parameters are replaced correctly
If you use a path for file with chars / or \ , the content of file is always macroquoted by hfs
another possibility is to use the macro {.load|test.tpl|var=function.} and use {.^function|a|b|c.}
with the last one and macroquote inside test.tpl, you have to use {.dequote|{.^function|a|b|c.}.}
;)
-
nice.
does it work? :)
-
yes working : ;)
udapted previous post
{.set|raybob|{.dequote|{.load|test.tpl.}.}.} used with {.^raybob|a|b|c.}
{.load|test.tpl|var=raybob.} used with {.dequote|{.^raybob|a|b|c.}.}
{.dequote.} is only necessary with quoted text in file or path file with "/" or "\" chars
remember that there is a section called [special:begin] where it is possible to place the initialization of variables
[special:begin]
{.load|test.tpl|var=raybob.}
[box server info]
<fieldset id='serverinfo'>
<legend><img src="/~img0"> {.!Server information.}</legend>
<a href="http://www.rejetto.com/hfs/">HttpFileServer %version%</a>
<br />{.!Server time.}: %timestamp%
<br />{.!Server uptime.}: %uptime%
<br />{.^raybob|welcome|HFS|to.}
</fieldset>
test.tpl
{.add to log|loading test.tpl.}
$1 $3 $2
{.add to log|$1 $3 $2.}
{.add to log|End of loading.}
-
Nice! Although in my case test.tpl is a rather large script that I don't want to have immediately loaded into memory for every request (my function is in HFS events).
My current solution is to keep the function quoted but do something like this:
{.set|function|{:{.set|a|$1.}{.set|b|$2.}{.set|c|$3.}{.load|test.tpl.}
and replacing all instances of $1 $2 and $3 in test.tpl with ^a ^b and ^c .
-
{.set|function|{:{.set|a|$1.}{.set|b|$2.}{.set|c|$3.}{.load|test.tpl.}
{.load|test.tpl.} must be placed outside the quote, whether you liked the contents of the file is included in "function", the quotes are there to prevent that the code is interpreted
{.set|function| {: {.set|a|$1.}{.set|b|$2.}{.set|c|$3.} :} {.load|test.tpl.} .}
if you plan to use {.^a.} {.^b.} {.^c.} or combinations of them in test.tpl , it is easier to replace them with $1,$2, ... directly
it would be easier to show us that will contain the file test.tpl order to determine the best solution
a question to me: why your position is it placed in the events?
(my function is in HFS events)
-
I have a 'functions.tpl' that is loaded in hfs.events under [request] . These functions are used globally in many places to make writing code easier so hfs.events most the most sense.
The reason that the entire function must be quoted is because I don't want it to be interpreted until it's called on.
Everything works totally fine as it's written. The function refers to account-create.tpl, and once place it's used is ajax.submission.tpl.
The submission script is used in 2 places, plus I have a template of over 400KB, so the fewer places I have to put this the easier it is to maintain. Hence why I used it as a function.
-
instert inside your template hfs.tpl
[account-create|private]
{.load|account-create.tpl.}
[code][account-delete|private]
{.load|account-delete.tpl.}
and make changes in functions.tpl with
{.set|account-create|{:{.set|account-create-param1|$1.}{.set|account-create-param2|$2.}{.set|account-create-param3|$3.}[color=blue]{.$account-create.}[/color]:}.}
{.set|account-delete|{:{.set|account-delete-param1|$1.}{.set|account-delete-param2|$2.}{.set|account-delete-param3|$3.}[color=blue]{.$account-delete.}[/color]:}.}
then report if this work[/code]
-
I can imagine that would work fine (I know for a fact that variables carry over into sections, I've done it), but what would it accomplish, having a section instead of {.load.} ? My code works as I posted above.
-
Sorry, I thought there was still a worry, forget my last post ;)