From josh at narins.net Tue Oct 11 15:09:08 2005
From: josh at narins.net (Josh Narins)
Date: Tue Oct 11 15:09:23 2005
Subject: [Petal] Javascript and CSS
Message-ID: <20051011140908.GA22995@narins.net>
Going to do some dynamic javascript, where the function itself is
dynamic, and CSS is basically the same question.
The big question is basically the which properly goes
around the CSS and javascript for "older" browers.
That wouldn't happen here.
# set the javascript using perl
$tal->{javascript} = "function a(obj) { ... stuff ... }";
#template contains
Has anyone ever tried anything like this, with javascript, either?
Again, no will work.
Cheers,
Josh
From wsmith at hbslabs.com Tue Oct 11 15:31:42 2005
From: wsmith at hbslabs.com (Warren Smith)
Date: Tue Oct 11 15:35:24 2005
Subject: [Petal] Javascript and CSS
In-Reply-To: <20051011140908.GA22995@narins.net>
References: <20051011140908.GA22995@narins.net>
Message-ID: <434BCCCE.8010009@hbslabs.com>
Josh,
That will work if you do .
The structure tag tells TAL to not parse out html entities (<>, etc)
However, petal will give you some problems if you do something like this:
Petal has some intelligence built in so you can do:
However, if you want to interpolate variables into js, you will have to
do something like this:
Hope this helps,
-Warren
Josh Narins wrote:
>Going to do some dynamic javascript, where the function itself is
>dynamic, and CSS is basically the same question.
>
>The big question is basically the which properly goes
>around the CSS and javascript for "older" browers.
>
>That wouldn't happen here.
>
># set the javascript using perl
>$tal->{javascript} = "function a(obj) { ... stuff ... }";
>
>#template contains
>
>
>
>
>Has anyone ever tried anything like this, with javascript, either?
>Again, no will work.
>
>
>
>Cheers,
>Josh
>
>
From josh at narins.net Tue Oct 11 16:44:13 2005
From: josh at narins.net (Josh Narins)
Date: Tue Oct 11 16:44:34 2005
Subject: [Petal] Javascript and CSS
In-Reply-To: <434BCCCE.8010009@hbslabs.com>
References: <20051011140908.GA22995@narins.net> <434BCCCE.8010009@hbslabs.com>
Message-ID: <20051011154413.GA23292@narins.net>
Helped a lot, thanks.
This seems like appropriate cookbook material, imho.
The trick with the //
>
>
> However, if you want to interpolate variables into js, you will have to
> do something like this:
>
>
>
> Hope this helps,
>
> -Warren
> Josh Narins wrote:
>
> >Going to do some dynamic javascript, where the function itself is
> >dynamic, and CSS is basically the same question.
> >
> >The big question is basically the which properly goes
> >around the CSS and javascript for "older" browers.
> >
> >That wouldn't happen here.
> >
> ># set the javascript using perl
> >$tal->{javascript} = "function a(obj) { ... stuff ... }";
> >
> >#template contains
> >
> >
> >
> >
> >Has anyone ever tried anything like this, with javascript, either?
> >Again, no will work.
> >
> >
> >
> >Cheers,
> >Josh
> >
> >
>
From josh at narins.net Fri Oct 14 17:43:17 2005
From: josh at narins.net (Josh Narins)
Date: Fri Oct 14 17:43:34 2005
Subject: [Petal] Auto omit-tag
Message-ID: <20051014164317.GA7783@narins.net>
I tend to use the same tag, over and over, to identify to me that I am
going to omit the tag (petal:omit-tag="string:1"). I generally use
tables and not divs, so if I see
, I know there is an omit-tag at
the end.
Any chance there could be a feature that automatically omitted a
specified tag? , for example.
I use them for control structures, like repeats and conditions.
Not a huge deal, but it might be nice.
-Josh
From wsmith at hbslabs.com Fri Oct 14 20:17:00 2005
From: wsmith at hbslabs.com (Warren Smith)
Date: Fri Oct 14 20:21:03 2005
Subject: [Petal] Auto omit-tag
In-Reply-To: <20051014164317.GA7783@narins.net>
References: <20051014164317.GA7783@narins.net>
Message-ID: <4350042C.6070309@hbslabs.com>
Petal only understands attributes and not tags (I think). There are a
couple of options to save typing:
1. Put this as part of your root tag:
Then you can type tal: instead of petal:
2. use this will replace the
entire tag with the value of path/to/var
3. Technically will eliminate the tag. It's
not in the spec, but saves typing.
4. Use the shorthand ${path/to/var}. It violates some of the principals
of Petal, but is rather handy.
Hope this helps,
Warren
Josh Narins wrote:
>I tend to use the same tag, over and over, to identify to me that I am
>going to omit the tag (petal:omit-tag="string:1"). I generally use
>tables and not divs, so if I see
, I know there is an omit-tag at
>the end.
>
>Any chance there could be a feature that automatically omitted a
>specified tag? , for example.
>
>I use them for control structures, like repeats and conditions.
>
>Not a huge deal, but it might be nice.
>
>-Josh
>
>
From wsmith at hbslabs.com Fri Oct 14 20:20:30 2005
From: wsmith at hbslabs.com (Warren Smith)
Date: Fri Oct 14 20:24:23 2005
Subject: [Petal] Auto omit-tag
In-Reply-To: <4350042C.6070309@hbslabs.com>
References: <20051014164317.GA7783@narins.net> <4350042C.6070309@hbslabs.com>
Message-ID: <435004FE.6030200@hbslabs.com>
*sigh*
My High School English Teacher would kill me for that grammar.
s/principal/principle/;
-Warren
Warren Smith wrote:
>
> Petal only understands attributes and not tags (I think). There are a
> couple of options to save typing:
>
> 1. Put this as part of your root tag:
>
>
> Then you can type tal: instead of petal:
>
> 2. use this will replace the
> entire tag with the value of path/to/var
>
> 3. Technically will eliminate the tag.
> It's not in the spec, but saves typing.
> 4. Use the shorthand ${path/to/var}. It violates some of the
> principals of Petal, but is rather handy.
>
> Hope this helps,
>
> Warren
>
> Josh Narins wrote:
>
>> I tend to use the same tag, over and over, to identify to me that I am
>> going to omit the tag (petal:omit-tag="string:1"). I generally use
>> tables and not divs, so if I see
, I know there is an omit-tag at
>> the end.
>>
>> Any chance there could be a feature that automatically omitted a
>> specified tag? , for example.
>>
>> I use them for control structures, like repeats and conditions.
>>
>> Not a huge deal, but it might be nice.
>>
>> -Josh
>>
>>
>
From petal-list at 2xlp.com Sat Oct 15 03:10:30 2005
From: petal-list at 2xlp.com (Jonathan)
Date: Sat Oct 15 03:54:36 2005
Subject: [Petal] Auto omit-tag
In-Reply-To: <20051014164317.GA7783@narins.net>
References: <20051014164317.GA7783@narins.net>
Message-ID: <84123F8F-44D3-44B7-B0F8-BFCA521C1B2D@2xlp.com>
that could be cool for petal... but it could cause a lot more
problems -- petal would understand it, while other TAL
implementations probably wouldn't - so your TAL documents wouldn't be
portable.
On Oct 14, 2005, at 12:43 PM, Josh Narins wrote:
> Any chance there could be a feature that automatically omitted a
> specified tag? , for example.
From josh at narins.net Tue Oct 18 21:36:45 2005
From: josh at narins.net (Josh Narins)
Date: Tue Oct 18 21:36:59 2005
Subject: [Petal] Calling template?
Message-ID: <20051018203645.GA16149@narins.net>
Can I determine which template is calling the one I am in?
I have a shared component, I can get around it, but was just wondering.
tia,
Josh
From petal-list at 2xlp.com Wed Oct 26 16:33:20 2005
From: petal-list at 2xlp.com (Jonathan)
Date: Wed Oct 26 16:33:50 2005
Subject: [Petal] Interpolating Form Data Tactic
In-Reply-To: <8750299605090114316271b045@mail.gmail.com>
References: <20050826195710.GB463@narins.net>
<20050901151420.GA1918@narins.net>
<8750299605090114316271b045@mail.gmail.com>
Message-ID:
I've settled on a standard method that i've found super comfortable
for interpolating form data with static TAL files.
Just wanted to share it with the list, as a few friends who tried
this really liked this way of setting up data structure for
interpolation and have adopted it too.
I create a 'Defaults' data structure for the form data with _checked,
_text and _selectxml/_selected sub-structures to handle form info
based on the type
the _selectxml data is not processed in tal, it easily could be -- i
just had already written a bunch of routines that already did that
stuff outside of tal.
anyways, the perl looks like this:
my %Defaults' =
(
'_checked' =>
{
'fieldname' =>
{
'fieldvalue' => 'checked'
}
}
,
'_text' =>
{
'fieldname' = 'fieldvalue',
},
'_selected' =>
{
'fieldname' = 'selected',
},
'_selectxml' =>
{
'fieldname' = 'structured xml',
},
);
and the html looks like this:
Text
First Name
Radio
Male
Female
Checkbox
Yes
Multiple Checkboxes
Item 1
Item 2
Item 3
Select
or
Select
It works really well for me - and it's made my perl and html much
more readable and accessible to others.
From petal-list at 2xlp.com Fri Oct 28 23:48:46 2005
From: petal-list at 2xlp.com (Jonathan)
Date: Fri Oct 28 23:49:06 2005
Subject: [Petal] false:EXPRESSION vs not:EXPRESSION
Message-ID:
is there any reason why petal uses false:EXPRESSION instead of
not:EXPRESSION ( which is the way TAL is originally implemented) ?
it's easy to work around this, either with using 'false' in the
templates or extending petal with a modifier to recognize 'not'
i understand the need for a perlish true/false vs the pythonic not --
i'm just wondering why petal doesn't support it with an alias so that
templates originally written for python or another implementation
will work right out of the box.
From bruno at mkdoc.com Sat Oct 29 00:09:46 2005
From: bruno at mkdoc.com (Bruno Postle)
Date: Sat Oct 29 00:09:55 2005
Subject: [Petal] false:EXPRESSION vs not:EXPRESSION
In-Reply-To:
References:
Message-ID: <20051028230946.GB1560@webarchitects.co.uk>
On Fri 28-Oct-2005 at 18:48 -0400, Jonathan wrote:
>
> is there any reason why petal uses false:EXPRESSION instead of
> not:EXPRESSION ( which is the way TAL is originally implemented) ?
It would be trivial to add it to Petal::Hash, I couldn't say why it
wasn't implemented like this in the first place.
A similar question: can someone remind me why all the modifiers in
Petal::Utils were never merged into Petal?
--
Bruno
From jvanasco at 2xlp.com Sat Oct 29 00:24:16 2005
From: jvanasco at 2xlp.com (Jonathan)
Date: Sat Oct 29 00:27:57 2005
Subject: [Petal] false:EXPRESSION vs not:EXPRESSION
In-Reply-To: <20051028230946.GB1560@webarchitects.co.uk>
References:
<20051028230946.GB1560@webarchitects.co.uk>
Message-ID: <2312F4A7-11E8-4B8E-BCE5-9F6F6A670826@2xlp.com>
On Oct 28, 2005, at 7:09 PM, Bruno Postle wrote:
>
> It would be trivial to add it to Petal::Hash, I couldn't say why it
> wasn't implemented like this in the first place.
I've just been overriding it ( i didn't want to touch the source )
with a simple one-liner after my include:
$Petal::Hash::MODIFIERS->{'not:'} = sub { return ( $_[0]-
>fetch($_[1]) ? 0 : 1 ); };
From reading the docs, it seems that the source somehow supports
aliasing of functions, but I didn't want to touch that trying to
patch things. I'm really not good with that sort of stuff.