Justin W | 12 Oct 19:43

Mdifiers to create attributes and custom field types?


I'm wondering if either of two things are possible in Petal.

1) A modifier that can create a series of element attributes.  Ideally,
something like:

<tag tal:attributes='modifier --${some/hashref}' />

Wherein modifier would return a data structure/string/something that would
allow it to make lots of attributes on tag.

And,

2) Is it possible to write a modifier that can inject a tag type?  I don't even
know how I would write this to give an example, but I'd like to be able to
dynamically generate the tag name itself based on output from a subtourine/data
structure/whatever.

Sometimes I'll want a <div, sometimes, I'll want a <span, sometimes, I might
want a <ul, who knows.

Thanks,
Justin

Gleb T. | 21 May 10:43
Favicon

Closing single tag problem.

Hello!
While writing small script for home use, I've found a strange behavior
of Petal. It's about closing single tags. I am use Petal for building
an rss feed, so I have to do something like this:

<atom:link petal:attributes="href feedlink" ... something .... />

Single tag. But Petal always auto-closes it, writing something un-validable:

<atom:link.... something ...></atom:link>

Is there a way to tell Petal, which tags must be left single? Or, just
switch off autoclosing?
I would not like to hack into Petal source, because it makes a good
start for future problems (with upgrade).

English is not my native language, sorry for possible errors.

Looking forward to hearing something, Gleb

Thedi Gerber | 2 Mar 09:54
Picon

Caching of method call results.

Hello,

I wrote a method which returns alternating 'even' and 'odd' for table rows:

sub row_class {
     my $self = shift;
     $self->{ row_class } = ! $self->{ row_class };
     return $self->{ row_class } ? 'even' : 'odd';
}

Actually the details are much more complicated, but the problem can be described with this example.

In a template I call this method

<tr class="odd"
     tal:attributes="class utils/row_class" >
...
<tr class="odd"
     tal:attributes="class utils/row_class" >

It seems that Petal caches method call results, hence I always get the same result from method 
row_class.

As a work around I tried to pass a dummy argument:

<tr class="odd"
     tal:attributes="class utils/row_class '1'" >
...
<tr class="odd"
     tal:attributes="class utils/row_class '2'" >
(Continue reading)

Thedi Gerber | 21 Aug 07:48
Picon

Bug report: Dollar follwed by a name gets lost

We are currently starting a new project and would like to use Petal. While doing some exercises to 
get to know it, i tried to include a small example perl script in a template. To my surprise, 
variable names in the perl source were lost.

After some more tests, I came to this conclusion:

$variable                         IN THE template magically disappears
$1000                             is ok
$n                                is ok (single letter following a $)
<span tal:content="xx">...</span> replaces the content always ok

Here is a small example:

---------------------------------- my template:
<html xml:lang="en"
lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://purl.org/petal/1.0/">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"/>
</head>
<body>

<p>
10 dollars are <b>$10</b>, n dollars are <b>$n</b>,
but nn dollars disapear <b>$nn</b>!
</p>

</body>
</html>
(Continue reading)

Peter Rabbitson | 23 May 16:32
Picon

Petal alters XML as if it is XHTML

Hi,
I might be doing something wrong, but when explicitly feeding XML and 
outputting XML, the result has all self closing tags (e.g. <br />) split 
into two tags (e.g. <br></br>). How can I stop this from happening?

Here is a simple test script:

==============================================================
use warnings;
use strict;

use File::Spec::Functions qw/splitpath/;
use File::Temp ();
use Petal;

print "====\n$Petal::VERSION\n====\n\n";

my $fh = File::Temp->new or die "$@\n";

print $fh <<'EOD'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta name="generator" content="vi" />
		<title>Test Page</title>
	</head>
(Continue reading)

Jonathan Vanasco | 3 May 19:51

omit-tag -- Petal DOCUMENTATION inconsistency with TAL spec


I just learned this on another TAL list...

regarding omit-tag, the TAL spec states

	If the expression evaluates to a true value, *** or there is no  
expression ***

ie: no conditional/statement is interpreted as true

whereas the Petal implementation states:

	If you want to ALWAYS remove a tag, you can use omit-tag="string:1"

The petal behavior should be

	If you want to ALWAYS remove a tag, you should use omit-tag=""

It looks as if this was implemented in v1.06  -- but the docs were  
never updated to reflect the correct behavior.

Alexander mcLander | 17 Apr 14:58
Picon
Favicon

Petal namespace

Hi, friends.

Is it posible to make additional parameter for Petal constructor.

When Petal used in portlets it's two not useful ways:
1. Specifing namespace in first tag of portlet
2. Usinng "petal:" name space instead of "tal:"

Is it posible to specify namespaces in constructor? 

For sample:

  my $portlet = new Petal (file=>'portlet.xml', namespace => 'tal');
  print $portlet->process ({name => 'Ivan'});

Joachim Zobel | 19 Mar 21:53
Picon
Favicon

i18nfool-extract does not decode Entities

Hi.

IMHO it should do that. There is no good reason a translator should need
to understand entity encoding.

Sincerely,
Joachim

Joachim Zobel | 16 Feb 21:36
Picon
Favicon

i18n:name - How do I use it

Hi.

I have a template containing 

<p i18n:translate="">First we want to test 
<span style="font-style: italic;" i18n:name="names">names</span>.</p>

If I apply i18nfool-extract, I get 

msgid "First we want to test ${names}."
msgstr "First we want to test ${names}."

and manually add

msgid "names"
msgstr "names"

Then I i18fool-update and edit the pot-File for de_DE to

msgid "First we want to test ${names}."
msgstr "Zuerst wollen wir ${names} testen."

msgid "names"
msgstr "Namen"

However after processing this with Petal I get

<p>Zuerst wollen wir <span style="font-style: italic;">names</span>
testen.</p>

(Continue reading)

Joachim Zobel | 4 Feb 12:08
Picon
Favicon

Pluggable expression language

Hi.

I am researching for what I call Apache2::TAL. The idea is to implement
an apache output filter, that processes XML, putting it into a TAL
template. This would be straight forward using Petal if I could plug in
another expression language. The natural language in my case is XPath. 

can this be done?

Any hints appreciated.
Joachim

Jonathan Vanasco | 2 Jan 21:24

escaping "." in variable names

Does anyone know if it is possible to use "." in variable names with  
petal -- and if so, how?

i have a dictionary/hash that has some keys that are named  
"section.subsection" , and I'm trying to get petal to show them

// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -


Gmane