Jonathan Vanasco | 1 Feb 18:17

Is even/odd working in the current version?

That's pretty much self explanatory

This is in the docs:
=pod
   <table>
     <div
       tal:omit-tag=""
       tal:repeat="audience self/audiences"
     >
       <tr
         class="odd"
         tal:condition="true: audience/odd"
       >
         <td>
           This a odd row, it comes before the even row.
         </td>
       </tr>
       <tr
         class="even"
         tal:condition="true: audience/even"
       >
         <td>
           This a even row.
         </td>
       </tr>
     </div>
   </table>
=cut

i'm getting false for both even and odd
(Continue reading)

Bruno Postle | 3 Feb 00:22
X-Face

Re: Is even/odd working in the current version?

On Wed 01-Feb-2006 at 12:17 -0500, Jonathan Vanasco wrote:
>
>This is in the docs:

>   <table>
>     <div
>       tal:omit-tag=""
>       tal:repeat="audience self/audiences"
>     >
>       <tr
>         class="odd"
>         tal:condition="true: audience/odd"
>       >
>         <td>
>           This a odd row, it comes before the even row.
>         </td>
>       </tr>
>       <tr
>         class="even"
>         tal:condition="true: audience/even"
>       >
>         <td>
>           This a even row.
>         </td>
>       </tr>
>     </div>
>   </table>

Documentation bug, it should say:

(Continue reading)

Jonathan Vanasco | 3 Feb 21:59

Documentation Suggestion

RE:
	Petal/Cookbook
	Generating even/odd rows (submitted by Warren Smith)

First- The decode modifier is GREAT.

Unfortunately though, I can't use it as I use Petal to share  
templates between different languages.
For those that need to do the same , there is a way to assign  
attributes based on repeat characteristics in pure TAL

===

<div tal:repeat="row rows">
	<tag tal:omit-tag="string:1" tal:condition="repeat/even"><tag  
tal:define="rowClass string:rowEven" tal:omit-tag="string:1"/></tag>
	<tag tal:omit-tag="string:1" tal:condition="repeat/odd"><tag  
tal:define="rowClass string:rowOdd" tal:omit-tag="string:1"/></tag>
	<div
		tal:attributes="class rowClass"
	>
	This will use either the rowEven or rowOdd class. All of the 'tag'  
elements are omitted on render. This uses a nested define tag in a  
condition tag, because define precedes condition in order of operations.
	</div>
<div>

===

The above is ugly and inefficient. , but if decode: is not an option,  
(Continue reading)

Jonathan Vanasco | 5 Feb 00:19

Pre-Caching?

First off - I'm running my Petal stuff in mod-perl

I'd like to pre-cache all of my Petal templates (they're in their own  
directory structure) during Apache startup in my startup.pl file,  so  
they get pulled into the main memory pool.

Does anyone here have a recommended way of doing this? 

Bruno Postle | 6 Feb 11:49
X-Face

Re: Documentation Suggestion

On Fri 03-Feb-2006 at 15:59 -0500, Jonathan Vanasco wrote:

>	Petal/Cookbook
>	Generating even/odd rows (submitted by Warren Smith)

> For those that need to do the same , there is a way to assign  
> attributes based on repeat characteristics in pure TAL

Ok done, I also added a simple example of doing it by duplicating 
the code for each of the odd and even styles.

--

-- 
Bruno

Jonathan Vanasco | 17 Feb 03:41

Help ? Trying to pre-cache

I'm running petal under mod perl

i'm trying to pre-cache the Petal templates before Apache forks, so i  
can use the Petal memory cache.

my issue is this:
	
	petal has the fatal error "Cannot find value for ... (FATAL)"

based on the petal intenral chart:
     1. Read the source XML template
     2. $INPUT (XML or HTML) throws XML events from the source file
     3. $OUTPUT (XML or HTML) uses these XML events to canonicalize  
the template
     4. Petal::CodeGenerator turns the canonical template into Perl code
     5. Petal::Cache::Disk caches the Perl code on disk
     6. Petal turns the perl code into a subroutine
     7. Petal::Cache::Memory caches the subroutine in memory
     8. Petal executes the subroutine
     9. (optional) Petal internationalizes the resulting output.

I need to stick something between 7&8 to return true.  can anyone  
point me to a line in Petal where that about happens?

i figure some sort of option in the constructor, when set, could  
bypass that.  i'd be happy to try and write the patch for that - i  
just can't figure out where to start.

i tried using the function
	perl -MPetal -e code template.xml
(Continue reading)

Jonathan | 17 Feb 08:49

Re: Help ? Trying to pre-cache - Patch Submission


I figured a way to achieve what I wanted with Petal

A patch is included below for Petal.pm that updates the Code and  
inline POD

The patch simply does this:
	1- add a "cache_only" option to templates (default 0) ( the internal  
var is $CACHE_ONLY )
	2- if cache_only is set, Petal returns true (1) after the eval block  
that attempts to interpolate data into the template ( and a line  
before Petal would otherwise have a fatal error if no data is passed  
in )

There is probably another way to do this, but this worked and only   
took me 1hr of blindly stabbing into code.

Why would this be beneficial?

If you're using Apache pre-fork, you can use a simple directory  
recursion to Petal objects and process the templates in startup.pl  
without passing in any data (Petal would otherwise give a fatal  
error).  This lets you consolidate the petal code into the shared  
memory pool of the parent process.

======================================================================== 
==

--- Petal.pm	2006-01-17 08:02:20.000000000 -0500
+++ newPetal.pm	2006-02-17 02:38:13.000000000 -0500
(Continue reading)

Bruno Postle | 24 Feb 14:21
X-Face

Re: Help ? Trying to pre-cache - Patch Submission

On Fri 17-Feb-2006 at 02:49 -0500, Jonathan wrote:

> The patch simply does this:
>	1- add a "cache_only" option to templates (default 0) ( the 
>	internal var is $CACHE_ONLY )
>	2- if cache_only is set, Petal returns true (1) after the 
>	eval block that attempts to interpolate data into the 
>	template ( and a line  before Petal would otherwise have a 
>	fatal error if no data is passed  in )

This looks useful and shouldn't break anything.

Can you send the patch again as an attachment?  The inline version 
is mangled by line-wrapping and I can't get it to apply.

--

-- 
Bruno

adam | 3 Mar 16:54
Picon

metal:use-macro should be TALES?

Howdy.

I'm fairly new to petal, and have been battling through the standard problems (overcoming my aversion to &amp;s in hrefs, javascript stuff etc etc), but am stumped on the latest one.

Basically I want to choose which metal template to use at run-time, using something along the lines of

metal:use-macro="dat/header" or
metal:use-macro="foo/${dat/bar}/baz.xml" or
metal:use-macro="string: dat/header"

Is this supported? Should I be doing something entirely different?

Thanks for your help,
--
Adam

Jonathan Vanasco | 3 Mar 17:54

Re: metal:use-macro should be TALES?

Usually for things like that, i do:

<tal tal:omit-tag="string:1" tal:define="dynVar foo/${dat/bar}/ 
baz.xml"/>
<span tal:attributes="class var"/>

I'm not sure if that will work in your example.

btw, you can just
	$processed =~ s/&amp;/&/g ;

i do that for a bunch of petal symbols when doing emails/etc

On Mar 3, 2006, at 10:54 AM, adam wrote:

> Howdy.
>
> I'm fairly new to petal, and have been battling through the  
> standard problems (overcoming my aversion to &amp;s in hrefs,  
> javascript stuff etc etc), but am stumped on the latest one.
>
> Basically I want to choose which metal template to use at run-time,  
> using something along the lines of
>
> metal:use-macro="dat/header" or
> metal:use-macro="foo/${dat/bar}/baz.xml" or
> metal:use-macro="string: dat/header"
>
> Is this supported? Should I be doing something entirely different?
>
> Thanks for your help,
> -- 
> Adam


Gmane