Kwartz feature requests

S

Shu-yu Guo

Kuwata-san he,

I would like to see support for ?-terminated methods in conditionals.
For example, something like the following:

<img src="locked.png" id="if:forum.locked?"/>

Right now, since Kwartz expects the ternary operator ? : when seeing a
?, this gives a parse error.

I would also like to see the following two, if possible:

* Ability to specify more than one logic file for a template, should be
trivial to implement.
* File inclusion directive, perhaps file: or include:

I've decided to adopt Kwartz as my template system for a forum I'm
writing, so reusing parts of the page through inclusion, like the header
and footer, would be optimal.

Thank you very much for your time,
 
A

Andreas Schwarz

S

Shu-yu Guo

The solution seems to be as simple as adding a || chr == ?? in Scanner#word?
 
M

Makoto Kuwata

Sorry for late reply.

Andreas said:
<span id="load:'first.plogic'"/>
<span id="load:'second.plogic'"/>


And you can specify several filename with '-p' option.
(It is undocumented yet.)

====================
bash$ kwartz -p file1.plogic,file2.plogic file.html
====================



Shu-yu Guo said:
I would like to see support for ?-terminated methods in conditionals.
For example, something like the following:

<img src="locked.png" id="if:forum.locked?"/>


I don't like it very much, because
* it is avairable only in Ruby.
(Kwartz is designed to be avairable in multi-language.)
* it is ambiguous with conditional operator (' ? : ').
(Those who use Kwartz are not all Ruby programmer.)

However, if you want to use '?-terminated methods' in Kwartz,
I consider it.

As a workaround, you can write it using raw-code, like the following:

Presentation data:
--------------------
<img src="locked.png" id="mark:forum_locked"/>
--------------------

Presentation logic (for eRuby):
--------------------
:elem(forum_locked)
:::<% if forum.locked? then %>
@stag
@cont
@etag
:::<% end %>
:end
--------------------

Output script(eRuby):
--------------------
<% if forum.locked? then %>
<img src="locked.png"/>
<% end %>
--------------------

For detail, see
http://www.kuwata-lab.com/webtech/kwartz/users-guide.en.04.html#pl-rawcode
http://www.kuwata-lab.com/webtech/kwartz/users-guide.en.06.html#tips-eruby


The solution seems to be as simple as adding a || chr == ?? in Scanner#word?

I may add a command option something like '--enable_special_metbhod=true'.
(could you propose better name?),
or add a function R() which represents raw-code.
(This is just my idea, not a plan.)

Presentation data:
 
S

Shu-yu Guo

Makoto said:
Sorry for late reply.
Quite all right. :)

As a workaround, you can write it using raw-code, like the following:
Actually, what I do now is just to alias the Scanner#word? method.
Because I had to write a custom Translator class anyways to fit the
output into my system, I figured I might as well just alias the method.
Then I include this file with the new Translator class and aliased
methods into a special version of the kwartz script, and everything
works to my liking.

If you don't want to add anything, then don't. Ruby programmers, who
have access to the full internal of Kwartz, can change behavior without
even hacking up kwartz.rb. Because of this ability, it's probably not
worth it for you to add another special case.

On a sidenote, the Analyzer is really useful. :) My translator generates
different variable names depending on scope.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top