Kwartz feature requests

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,

···


That’s some catch, that Catch-22.
Oh, it’s the best there is.

Shu-yu Guo wrote:

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:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/95819

I’ve decided to adopt Kwartz as my template system for a forum I’m
writing

You too?

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

···


Lo-lee-ta: the tip of the tongue taking a trip of three
steps down the palate to tap, at three, on the teeth.
Lo. Lee. Ta. GUO Shu-yu shu@rufuran.org

Andreas Schwarz wrote:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/95819

Bah, now I feel stupid. :slight_smile:

You too?

Quite, it seems to be a better system than what I wrote on my own, so
why not.

···


That’s some catch, that Catch-22.
Oh, it’s the best there is.

Sorry for late reply.

Andreas Schwarz wrote:

Shu-yu Guo wrote:

  • Ability to specify more than one logic file for a template, should be
    trivial to implement.

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 wrote:

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

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:


Presentation logic (for eRuby):

:elem(forum_locked)
:::<% if forum.locked? then %>
@stag
@cont
@etag
:::<% end %>
:end

Output script(eRuby):

<% if forum.locked? then %>

<% 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:


Intermediate code:

:if(R(‘forum.locked?’))
:print(‘\n’)
:end

Output script(Ruby):

if forum.locked? then
print “<img src="locked.png"/>\n”
end


regards,
kwa

Makoto Kuwata wrote:

Sorry for late reply.

Quite all right. :slight_smile:

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. :slight_smile: My translator generates
different variable names depending on scope.

···


That’s some catch, that Catch-22.
Oh, it’s the best there is.