Prototype.js, etc.

1 view
Skip to first unread message

Lee

unread,
May 18, 2007, 2:21:44 PM5/18/07
to sgte - A simple Erlang Template Engine
I've been using SGTE for a project which also uses prototype.js and
jQuery. As you're probably aware, they both use the $('obj') syntax
for virtually everything, and it's become a bit of an annoyance to
escape it with \$ or $$ every time.

So, I'd like to recommend a special case for '$(', as implemented in
the patch at the bottom of this message.

I'm sure there's a better way to ignore '$' in these cases. In fact,
it may be more appropriate to have a list of characters to include
rather than a list of characters to exclude.

What do you think? Should I just suck it up and continue to use "\$"
in all my jQuery code?

Thanks

-lee

--- sgte-0.4.1.orig/src/sgte_parse.erl 2007-05-18 12:57:01.100403416
-0500
+++ sgte-0.4.1/src/sgte_parse.erl 2007-05-18 13:12:36.922136888
-0500
@@ -149,6 +149,8 @@
parse(Rest1, [{ift, ParsedIf, Line}|Parsed], Line)
end
end;
+parse([H,H1|T], Parsed, Line) when H == $$ andalso H1 == $( ->
+ parse(T, [H1,H|Parsed], Line);
parse([H|T], Parsed, Line) when H == $$ andalso hd(T) == $$ ->
parse(tl(T), [H|Parsed], Line);
parse([H|T], Parsed, Line) when H == $$ ->

Filippo Pacini

unread,
May 19, 2007, 8:22:27 AM5/19/07
to Lee, sgte - A simple Erlang Template Engine
Hi,
I use prototype too and it's annoying having to escape all the $,
however I don't like very much the idea of having a special case for
parsing '$('.

In the trunk I've added options to control some aspects of the
rendering. I could add a 'prototype_jquery_suopport' option to handle
these cases.

What do you think of this solution?

filippo

Lee Teague

unread,
May 19, 2007, 9:03:25 AM5/19/07
to Filippo Pacini, sgte - A simple Erlang Template Engine
To be honest, I don't like having special cases, either, I just wanted to bring this up for discussion.

Rather than a 'prototype_jquery_support' option, how about a 'nonatom_character_support', then change the default behaviour to only support keywords that look like a valid erlang atom ([a-z])? 

-lee
--
lte...@dashf.com

Filippo Pacini

unread,
May 19, 2007, 11:30:11 AM5/19/07
to Lee Teague, sgte - A simple Erlang Template Engine
Allowing only some characters (i.e. a-zA-Z_) as the beginning of an
attribute should be a good solution.

There also shouldn't be the need for 'nonatom_character_support'. BTW
something like '(\'someId\')' is a valid erlang atom :-).

I've made the changes in the trunk. It seems to work. Let me know if you
have problems.

cheers,
filippo

Lee Teague wrote:
> To be honest, I don't like having special cases, either, I just wanted
> to bring this up for discussion.
>
> Rather than a 'prototype_jquery_support' option, how about a
> 'nonatom_character_support', then change the default behaviour to only
> support keywords that look like a valid erlang atom ([a-z])?
>
> -lee
>
>

> On 5/19/07, *Filippo Pacini* <filippo...@gmail.com

> lte...@dashf.com <mailto:lte...@dashf.com>

Reply all
Reply to author
Forward
0 new messages