rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: tsaukpaetra on April 23, 2008, 05:10:10 AM
-
;D Just playing around with the templates macro function and I was trying to solve an "issue":
I have been working on creating a sort of "forum" using hfs. (almost usable)
During posting of a message (merely using a macro to write a folder (see the Rawr template's shoutbox example)) I write html code for the center text area in the files listing (in the Rawr template) to show the message.
This is the problem: Attempting to tell the {.append or {.save macros to save text with a macro in it (i.e. has {. in it) then HFS parses the macro before writing the file!
I understand this is on purpose as to the wiki: http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros#Problem (http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros#Problem)
However, when using the proposed solution (wrapping it in {{\ /}} comment tags), the macros are indeed left untouched, but where the comment tags are are "{:" and ":}" (which I take to mean another way to comment out a macro).
The result of loading any file with these tags ( the {: :} ones) using {.load seems to crash the macro system for that page load, as all macros are left uninterpreted after the {.load statement (not to mention the {.load statement fails).
However, loading files with legitimate macro commands ({.if etc...) leaves the macros uninterpreted.
So:
1.) How do I write the code inside a {.append or {.save macro so that macros inside will be written uninterpreted (and apparently without {: :} tags)
2.) How do I load a file so that macro commands inside of it are interpreted?
Thanks,
Tsaukpaetra
-
1.) How do I write the code inside a {.append or {.save macro so that macros inside will be written uninterpreted (and apparently without {: :} tags)
2.) How do I load a file so that macro commands inside of it are interpreted?
1.) I asked this question once, and although it was very hard I did manage to get it to work. I dont remember how though :(
2.) You have to use dequote around the load macro.
-
1. if you solve problem 2, you don't need to solve problem 1.
2. use {.dequote|{.load|file.}.}
it will just remove starting and ending :} (if present)
removing them will unleash the execution
-
1. if you solve problem 2, you don't need to solve problem 1.
Actually, the condition two of question 1 is the important part: In order to use {.dequote to successfully unleash external macro execution, there must BE no quotes (bug?)
2. use {.dequote|{.load|file.}.}
it will just remove starting and ending :} (if present)
removing them will unleash the execution
By testing a little, I have found the following:
using {.load| only (no dequote) will just read out the file specified (if there are no {: :} tags).
Using {.load on a file with quotes seemingly stops macro execution for the remainder of the request. (in the Rawr template, this leaves a bunch of uninterpreted macro code visible on the page)
Using {.dequote|{.load| on a file that has any {: :} tags (macros included or not) also has the effect of "crashing" the macro interpreter.
However, using {.dequote|{.load| on a file that has macro commands but not comments will allow the external file's macros to be executed as expected.
By the way, I am testing this using build #185.
On a side note, how would I go about escaping the percent signs when writing using {.append or {.save?
The purpose of my problems is that I wish to try to save bandwidth by only allowing logged-in users to edit thier own posts, (currently the post is transfered twice, one for display, one for editing) and an example code that could do this is:
{.if|{.=|%user%|hard-coded-username.}|output editor code|otherwise don't do anything.} (in the outputted file)
Unfortunately, if I write %user% anywhere in a template or macro HFS of course interprets it and fills in the username ::) :-\ whether I want it to be written to a file or interpreted like normal ;).
I have setup a sandbox site to demonstrate what happens Here (http://wizardht.is-a-geek.net:8089). I think all of the test posts inside are named the same (check using ?tpl=list&folders-filter=\&recursive)
-
Unfortunately, if I write %user% anywhere in a template or macro HFS of course interprets it and fills in the username whether I want it to be written to a file or interpreted like normal .
All the variables (%var%) are internally replaced by hfs, if there seems not be a possibility by using quotes {: %user%:}, the solution is to split up the text to be written:
{.append| filedest |%.}{.append| filedest |user.}{.append| filedest |%.}
or
{.append| filedest |%user.}{.append| filedest |%.}
or
{.append| filedest |%.}{.append| filedest |user%.}
-
Using {.dequote|{.load| on a file that has any {: :} tags (macros included or not) also has the effect of "crashing" the macro interpreter.
crash? can you supply a minimal but detailed procedure to reproduce this problem?
-
It is very hard to use macro's in external files, I suggest looking at using string tables and all of the processing inside the template.