[PHPTAL] Localization confusion

2012-10-14 Thread Tjerk Meesters
Hi,

While putting my localization strings in place I discovered an interesting
quirk that perhaps someone could explain.

This is my construct:

title tal:content=title|default i18n:translate=foo bar/title

The idea is that a page can override the default page title by setting the
title variable. If not specified, the page title should be translated from
whatever is in the template (i.e. foo bar).

The outcome of my construct is I18N(foo bar) . foo bar - the
translation of foo bar followed by foo bar itself. Setting the title
variable has no effect.

Has anyone come across this? And is there an easy fix for what I need?

Version = 1.2.2


-- 
--
Tjerk
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Escaping ${} and $

2011-09-02 Thread Tjerk Meesters
Hi,

Small typo, should be 'escape' instead of 'exscape' ;)
On Sep 3, 2011 3:06 AM, Kornel Lesiński kor...@geekhood.net wrote:
 On Fri, 02 Sep 2011 09:59:51 +0100, Tarjei Huse tar...@scanmine.com
 wrote:

 Hi, I'm trying to include a JQuery template containing ${} into a
 PHPTal template. Is there a way to say do not use phptal within this
 block or just escape the $ signs?

 Yes, $${} will be printed as ${} in generated HTML.


 Thanks, please consider the attached patch to the manual.

 Excellent! Thanks!

 http://phptal.org/manual/en/split/variableRefs.html

 --
 regards, Kornel Lesiński

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] [PATCH] Shouldn't skip over __get() just because __isset() was defined…

2011-06-26 Thread Tjerk Meesters
On Mon, Jun 27, 2011 at 6:36 AM, Terin Stock terinjo...@gmail.com wrote:
 I've been working with PHPTAL for quite some time, and have always been
 annoyed that from within the template an object's __get method was being
 ignored. I think I've tracked down the bug (in version 1.2.2, though it
 still present in trunk).
 The scenario: an object, exampleObject, implements __isset, but returns
 false (exampleVariable is not set). exampleObject also implements __get, and
 returns something that isn't NULL.
 As __isset is implemented, the if condition on line 378 is satisfied, but
 because exampleVariable is not set, the if condition on line 379 is not met,
 and the loop does not continue.

Out of curiosity, why would it make sense to read a variable's content
when isset() returns false?


 However, since the if condition on line 385 (checking to see if __get is
 implemented) is an elseif, it is skipped–the condition on line 378
 passed–right to the if condition on line 394 (the one checking to see if
 __call is implemented). As exampleVariable isn't a method, it to fails, and
 the PHPTAL_Context:pathError method is executed.
 My patch is simple, changing one line. Everything seems to work as expected
 with the change, though I'm happy to hear any problems you have with it.
 diff --git a/PHPTAL/Context.php b/PHPTAL/Context.php
 --- a/PHPTAL/Context.php
 +++ b/PHPTAL/Context.php
 @@ -382,7 +382,7 @@ class PHPTAL_Context
                      }
                  }
                  // ask __get and discard if it returns null
 -                elseif (method_exists($base, '__get')) {
 +                if (method_exists($base, '__get')) {
                      $tmp = $base-$current;
                      if (null !== $tmp) {
                          $base = $tmp;
 --
 #Terin Stock
 Undergraduate, Computer Science (CISE), University of Florida

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal





-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Extending namespace

2011-06-10 Thread Tjerk Meesters
Why not just have tal:content=nl2br: var

Just define phptal_tales_nl2br() and voila :)
On Jun 10, 2011 12:03 PM, Hisateru Tanaka tanakahisat...@gmail.com
wrote:
 Hi,

 I'm trying to extend namespace of PHPTAL to use in my framework.
 3 new attributes would introduced.

 pal:content-nl2br
 pal:replace-nl2br
 pal:attr

 They might be things which some users wanted...

 Test code is here:
 https://gist.github.com/1016531
 Someone tell me which this implementation is even good or not.

 If developer team is planning to change class tree or public/protected
 method, how can I keep compatibility safer?

 --
 Hisateru Tanaka

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] tal:equal ?!

2011-04-13 Thread Tjerk Meesters
For the and operation I've written a modifier that turns all its arguments
into an array of booleans and then uses array_mult() to determine the
outcome for tal:condition.

array_sum could be used for the or-operation ;)
On Apr 14, 2011 2:27 AM, Kornel Lesiński kor...@geekhood.net wrote:
 On Wed, 13 Apr 2011 14:45:31 +0100, Ciprian Voicu pict...@autoportret.ro

 wrote:

 I've encountered lots of times the need to compare one or more pairs of
 values so I used php: modifier, but let's say would be more professional
 using some internal tal way instead of php native comparison way.

 eg:

 div tal:condition=php: listing.status == 'ACTIVE'  listing.type ==
 'PREMIER'print some good content here/div

 You could have method like isActivePremier() [or whatever name better
 describes state you're checking for] and use it like this:

 div tal:condition=listing/isActivePremier

 If the condition is related to your business rules, then I think that's
 the most appropriate way to do it.

 --
 regards, Kornel Lesiński

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] There is no namespace declared error in v. 1.2.1

2011-01-13 Thread Tjerk Meesters
Hi,

Just bumped into something similar.

I'm using a so-called skeleton.html (a big macro starting with html
and defining multiple slots for scripts, styles, content, popups,
etc.).

Let's say that I define xmlns:myns=http://example.org/myns; in the
html of my skeleton.html and then one of my slots gets filled by a
tag myns:fancystuff /

Using a PreFilter I can then expand the fancystuff / tag into ...
something fancy ;-)

Here's the problem; it throw an error, saying that the myns namespace
is not defined ... is that expected?


Best,
  Tjerk


2010/1/27 Kornel Lesiński kor...@aardvarkmedia.co.uk:
 On 27-01-2010 at 08:39:36 Murat Çorlu muratco...@gmail.com wrote:

 Is there a simple way to define a custom namespace globally for all of our
 templates like tal and metal namespaces?

 No, and I'm not planning to add it. TAL namespaces are already in violation
 of the XML spec.

 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal




-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] There is no namespace declared error in v. 1.2.1

2011-01-13 Thread Tjerk Meesters
On Jan 14, 2011 1:17 AM, Kornel Lesiński kor...@geekhood.net wrote:

 On Thu, 13 Jan 2011 10:22:52 -, Tjerk Meesters 
tjerk.meest...@gmail.com wrote:

 Here's the problem; it throw an error, saying that the myns namespace
 is not defined ... is that expected?


 Yes (if I understood correctly what you're trying to do).

 PHPTAL checks correctness of namespace declarations from perspective of
source files, not the output (it probably should check output too, but
that's a harder problem).

I would say it has to only check on the full output, but I also realize that
might be tougher ;)


 So if a file, looked at in isolation (before macros are executed), doesn't
have required xmlns, that's an error according to XML.


 I have a mixed feelings about enforcing XML strictness. It's sometimes
annoying, OTOH it's a bit dishonest to call TAL an XML language when it
doesn't play by XML rules.

Essentially I'm using my own namespaces to do on-the-fly replacements, after
which the namespaced element is gone, much like how the tal: is gone after
parsing the template, i.e. it only has meaning before that.

What I would like, therefore, is either:
a) a way to define my own namespace programmatically before parsing starts
b) a way to relax the parser so that namespace checking is not enforced,
like how tal ns is also not enforced
c) only do namespace checks on the output


 --
 regards, Kornel Lesiński


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Re: Feature request: Allow array as parameter of PHPTAL's set() method

2010-11-22 Thread Tjerk Meesters
Alternatively you could allow overloading set() to accept an array as its
only argument.
On Nov 22, 2010 8:40 PM, Anton Andriyevskyy x.meg...@gmail.com wrote:
 Separate method is good idea, but the name *setAll *may be confusing,
 you may think that it will replace the ones that you have set earlier with
 set(),
 as setAll looks like set all that template engine will see.

 Maybe something like setMultiple or setMany or just setArray will be more
 democratic?

 Anton Andriyevskyy
 Expert in Business Automation  Web Development



 On Mon, Nov 22, 2010 at 1:54 PM, Moritz Baumann flamin...@online.de
wrote:

 Kornel Lesiński kor...@... writes:

 
   $template = new PHPTAL($this-_viewDir . DS . $fileName);
   $template-set($this-_viewVars);
  
   Another thing that IMHO should be considered is that PHPTAL should
   implement ArrayAccess so you could do
   $template['menu'] = $menu;
  
   Would a patch for this be accepted?
 
  Sorry, no. That would duplicate $template-menu = $menu syntax, which
 works
 already.
 
  I agree about setting all variables in one call, but I'd add separate
 method
 for it (setAll?)

 Yeah, a separate method might be the better solution. The proposed
solution
 was
 just a 1:1 copy from the magento template class we're extending.

 Thank you  regards,
 Moritz





 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: AW: [PHPTAL] Minor feature request

2010-11-04 Thread Tjerk Meesters
Interestingly, that's what I ran into yesterday. Found out that while one
version of phptal hides any content inside the empty condition, another
(probably older) version would instead show it, causing a rather
embarrassing few minutes ;)
On Nov 4, 2010 4:49 PM, Per Bernhardt p...@webfactory.de wrote:
 Hey, use

 tal:block tal:replace=
 lots of html here
 /tal:block

 The documentation suggests this for creating samples in the templates...
http://phptal.org/manual/en/split/tal-replace.html

 Kind regards,
 Per



 -Ursprüngliche Nachricht-
 Von: phptal-boun...@lists.motion-twin.com [mailto:
phptal-boun...@lists.motion-twin.com] Im Auftrag von tarjei
 Gesendet: Donnerstag, 4. November 2010 09:15
 An: Template Attribute Language for PHP
 Betreff: [PHPTAL] Minor feature request

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi, would it be possible to get a false modifier for phptal so I could do:

 tal:block tal:condition=false
 lots of html here
 /tal:block

 And the content within would not be included in the output? Also one could
remove the whole part from the php template since it would never be
executed.

 This would be usefull as a technique for adding comments or for removing
parts of a page for some time.

 Regards,
 Tarjei Huse

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iEYEARECAAYFAkzSa5wACgkQYVRKCnSvzfIajgCgu9a3fD6Z3uR+1byhNL6qKvUr
 ZGAAnAlzPE2ylAqBdpye5TbUv8m0DTdL
 =o3XG
 -END PGP SIGNATURE-

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] require_once vs autoloading

2010-06-02 Thread Tjerk Meesters
Hi,

Zend uses spl_autoload_register() as well I believe, so that should be safe.

The main problem I can see is that if there's an existing __autoload()
function, spl_autoload_register() will replace it (as stated in the
manual). I don't think putting the autoloader in a separate file will
make a difference.

This will probably require a change in the major/minor revision
number, so that developers are aware that it may break their code.


Best,
  Tjerk

On Wed, Jun 2, 2010 at 5:33 PM, Robert Goldsmith rgoldsm...@names.co.uk wrote:
 No idea :)

 However, if you allowed for autoloading to be optional then if needed people 
 could turn it off and replace it with an external system such as Zend's. 
 Maybe moving the autoloader into its own file and telling people they need to 
 require_once the file if they wish to use the phptal autoloader.

 Robert

 On 2 Jun 2010, at 10:25, Kornel Lesiński wrote:

 On 02-06-2010 at 09:56:23 Robert Goldsmith rgoldsm...@names.co.uk wrote:

 I think autoloading is a good idea but please keep in mind that the app the 
 phptal is being used within may already have autoloading configured. a 
 prime example would be Zend.

 I've used spl_autoload_register(). Does it conflict with Zend?

 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal


 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal




-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] require_once vs autoloading

2010-06-02 Thread Tjerk Meesters
2010/6/2 Kornel Lesiński kor...@aardvarkmedia.co.uk:
 On 02-06-2010 at 11:10:43 Robert Goldsmith rgoldsm...@names.co.uk wrote:

 Why would someone choose to replace PHPTAL's autoload with something
 else? (I'm not implying it's perfect or such, just wondering what problem
 would such option solve).

 If people already have autoloader code and wish to use only one autoloader
 in their application or if they find the autoloader they are already using
 conflicts with the phptal one then it would be good to allow them to disable
 the phptal autoloader.

 require_once PHPTAL.php;
 spl_autoload_unregister(array('PHPTAL','autoload'));
 // if needed: spl_autoload_register('__autoload');

 Would that be OK?

Wouldn't that cause issues when PHPTAL needs to load more classes
during the course of the script's execution?

The autoloader stack should not cause any conflicts; if a class can't
be found based on the naming conventions of a particular class loader,
it will go to the next loader.

The argument that one would only want one autoloader is somewhat weak;
some other libraries also use their own loaders, so I see no reason to
resist that for purity sake. I don't mind to be proven wrong though
;-)

The magic required to get around my earlier __autoload() issue
should be the only thing that PHPTAL should be concerned about.


 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal




-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] require_once vs autoloading

2010-06-01 Thread Tjerk Meesters
I could be wrong here, but I think it's not so much any problem with
require_once as it is to reduce memory consumption while using the
library. This happens when developers only use 30% of the library and
yet the whole shebang is loaded on every request ;-)


On Wed, Jun 2, 2010 at 5:20 AM, romtek rom...@gmail.com wrote:
 Kornel, I've noticed this item on phptal.org: Removed all require_once and
 switched to autoloading. What are the problems with using require_once?
 Roman
 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal





-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] PHPTAL template for a calendar view?

2010-02-09 Thread Tjerk Meesters
Why not just use a client side calendar, such as those provided with  
jquery ui?




On 09-Feb-2010, at 19:12, Marco Pivetta ocram...@gmail.com wrote:

Didn't think about week days and weeks, sorry ^_^'' (Yeah, stupid  
mistake...)


2010/2/9 Kornel Lesinski kor...@aardvarkmedia.co.uk
On 9 Feb 2010, at 11:00, Marco Pivetta wrote:

 Isn't it simpler to build it with an ol and just some CSS? Table  
layout is not that good for calendars to me :\


table is, semantically, the best choice for a calendar. You have  
logical columns with days of week and logical rows with weeks.


A list would be inappropriate, as it would lose connection between  
headers and data, and in screen readers it would be more difficult  
to navigate – you couldn't easily jump to same day next week for exa 
mple.


As for building calendar with PHPTAL, I think you could use range()  
to build 1d array of days of the month, then array_unshift() number  
of days in the beginning to make 1st start on appropriate day of the  
week, array_chunk(,7) to split it into weeks, and append count%7  
days at the end.


Then in PHPTAL it would be straightforward 2 tal:repeats.

--
regards, Kornel


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal



--
Marco Pivetta - Ocramius Aethril
http://twitter.com/Ocramius
Sent from Padova, PD, Italy
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] i18n:translate and dynamic tal:content

2009-11-23 Thread Tjerk Meesters
Hi,

What do you mean by all-whitespace translation keys? I hope that
doesn't mean i18n:translate= will stop working, because we rely
heavily on this feature ;-)

On 11/23/09, Kornel Lesiński kor...@aardvarkmedia.co.uk wrote:
 On 22.11.2009, at 20:16, lo...@nic.fi wrote:

 I'v got a problem translating text that is printed dynamically from a
 mysql database. I'm printing body part names and the related muscle names
 by using nested tal:repeat. In the inner loop I'd like to echo the muscle
 name and translate it if there's a translation available. Here's what I
 got so far:

 ul
   li tal:repeat=bodyPart bodyParts
   tal:block tal:content=bodyPart/name /
   ul
   li tal:repeat=muscle php:bodyPart.Muscles
   tal:block i18n:translate=
   span tal:content=muscle/name /
   /tal:block
   /li
   /ul
   /li
 /ul

 .. but all that the inner loop prints is empty li elements. What am I
 doing wrong?

 Use this instead:

 tal:block i18n:translate=muscle/name


 i18n:translate= builds translation key at compile time, ignoring tags and
 dynamic content.

 i18n:translate=expression will use value of the expression as translation
 key.


 I've changed PHPTAL to reject all-whitespace translation keys. Version in
 SVN will now prevent this gotcha.

 --
 regards, Kornel




 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Advanced TALES

2009-11-18 Thread Tjerk Meesters
While I was looking at the pager example, I couldn't help but think
this could be fixed by having a few helper classes for this; helper
classes that would make your phptal code cleaner and abstract out
certain typical tasks of a pager.

The same could be said for the dropdown scenario. All in all, I hate
having explicit code in my templates, why can't things in phptal be
fixed in the phptal way? ;-)


Best,
  Tjerk

2009/11/18 Kornel Lesiński kor...@aardvarkmedia.co.uk:
 On 17-11-2009 at 18:42:50 Iván Montes drsl...@pollinimini.net wrote:

 After looking at the wiki page examples, couldn't we solve this with
 specialized tales modifiers?

 This is taken straight from one of my pages:

 a tal:condition=php:pager.getNumberOfPages() GT 1 AND
 pager.getCurrentPage() LT pager.getNumberOfPages()-1
 href=${php:pager.getURL(pager.getNumberOfPages())}#p${latest_post/id}Last
 »/a

 I could replace it with one-off special modifier, or redundant method in
 pager class, but I'm not sure if that's the best thing to do, and definitely
 it's not on path of least resistance.

 Why not write it like this:

 a tal:condition=pager/getNumberOfPages GT 1 AND pager/getCurrentPage LT
 pager/getNumberOfPages-1
 href=${pager/getURL(pager/getNumberOfPages)}#p${latest_post/id}Last »/a

 ?


 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal




-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Advanced TALES

2009-11-17 Thread Tjerk Meesters
To maintain proper bc I would suggest another namespace, like ntales (new tales)

The problem of modifier scope is difficult, unless you can introduce
syntax like this:

(php:foo()) + foo/bar

Braces around the modifier code would define the scope, but this is
still error prone if you decide to have something like php:foo('(hi')
in which the brace count would screw up unless you do tokenizing.

To be honest, to solve the option problem I just add a selected
attribute in my option list and add selected exists: row/selected
which works fine, no need to pass two variables into phptal.


On 11/17/09, Kornel Lesiński kor...@aardvarkmedia.co.uk wrote:

 There are few cases where simple TALES (expressions like foo/bar/baz)
 isn't working well, most often comparison of selected option, PHPTAL's
 pythonified/xmlized PHP syntax has gotchas and it's confusing to jump
 between the two.

 I think in that case best solution would be to make TALES more powerful,
 but I wonder how much powerful? Should I add math expressions? String
 concatenation? Should I allow passing of function arguments? What the
 syntax should be like?

 foo/bar EQ baz/quz

 foo/bar + baz/quz

 Should modifiers work inside TALES?

 How do you mark end of modifier's content?

 foo/bar + php:foo()

 php:foo() + bar/baz

 http://phptal.org/wiki/doku.php/improvedtales


 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Escaping of dollar sign ($)

2009-10-27 Thread Tjerk Meesters
I vote for not changing the current behaviour; I agree that if it's
documented, it can be a little weird ;-)

Personally I would choose to have a money formatter TALES construct,
because I hate having to go through my templates again when I start
adding another currency for instance.


Best,
  Tjerk

2009/10/27 Kornel Lesiński kor...@aardvarkmedia.co.uk:
 On 27-10-2009 at 12:34:42 Iván Montes drsl...@pollinimini.net wrote:

 I vote for not changing the behavior but I would like, for next major
 version of PHPTAL, to break BC for escaping and remove the escaping of
 the dollar symbol:

 ${variable} - variable
 $${variable} - $variable

 Since TAL is heavily based on HTML/XML semantics I guess it makes more
 sense to escape using unicode point codes (#36; for $) or custom
 entities.

 Unfortunately in XML it shouldn't matter whether you use literal $ or #36;
 (the difference is completely lost if you use W3C DOM for example).
 Theoretically PHPTAL should support #x24;#x7b;var#x7d; as well as ${var}
 :/

 Custom entities require custom DOCTYPE/DTD, and that's just a can of worms.


 This would remove the need for backtracking when parsing
 interpolatable texts and remove possible ambiguities like the one
 described in the original mail.

 It can be unambiguous. It just has to be clearly defined and implemented in
 one way or another :)

 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal




-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Conditions inside php:

2009-10-22 Thread Tjerk Meesters
Within php: context you should use option[0] instead to get the
first element of the option array

On 10/22/09, Kornel Lesiński kor...@aardvarkmedia.co.uk wrote:
 On 22-10-2009 at 14:09:42 Michael hosema...@poczta.onet.pl wrote:

 One more thing:
 My select statement:
 select name=id_country id=id_country
 tal:block tal:repeat=option id_country_arr
 option tal:attributes=selected php:isset(id_country_val) AND
 (id_country_val
 == option/0) value=${option/0}${option/1}/option
 /tal:block
 /select

 I have a problem with this statement:
 (id_country_val == option/0)
 it seems that phptal don't get the value of option/0

 When you use php: modifier, all TALES stops working. With php: modifier
 option/0 means divide option by zero.


 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] How do I access array keys?

2009-06-18 Thread Tjerk Meesters
Hmm we've seen this mistake being made a lot ;-) would it help if this
was documented under, like, things to consider when using php:
modifier? :)

On 6/18/09, Kornel Lesiński kor...@aardvarkmedia.co.uk wrote:
 On 18-06-2009 at 15:42:14 Igor Sverkos
 igor.sverkos+php...@googlemail.com wrote:

 If you don't have an object, just an array - how do I access a simple
 array key?

 With php: modifier you have to use [] for arrays, and . for objects.

 Template:
 =
 [...]
 tr tal:condition=exists: data tal:repeat=item data
 td tal:content=item/name /
 td tal:content=php: view_Helper_getDate(item.date) /
 /tr


 The first td-row will work.

 The second row will throw a Trying to get property of non-object...
 notice.

 Use item['date']

 item.date is only for objects, and will not work with arrays.

 --
 regards, Kornel

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Re: selected=

2009-06-15 Thread Tjerk Meesters
Hi,

As Kornel mentioned, this is fixed in the repos and it can be made to
work for older versions by using exists: isSelected instead of
isSelected | nothing

Hope that helps :)

On 6/16/09, Igor Sverkos igor.sverkos+php...@googlemail.com wrote:
 Hi,

 Tjerk Meesters wrote:
 Hmm I don't think using selected as the value is the solution to the
 exact problem here, because phptal does understand the so called
 binary attributes, such as selected and checked.

 Seems like the '| nothing' is causing the expression to change type
 and display a 1 instead of being treated in above special manner (I
 guess phptal uses === true for this?)

 If | nothing is the problem, how could I prevent an error, If isSelected
 isn't set?


 --
 Regards,
 Igor



 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] tal:repeat and php:

2009-05-24 Thread Tjerk Meesters
That's because you're using the php: construct; try
tal:condition=php: box['nr']  5

Though, usually - wherever I can - i insert the condition inside the
list of elements I'm iterating over, so that I don't have to use php:


Best,
  Tjerk

On Sun, May 24, 2009 at 6:13 PM, Dominique Sandoz j...@gmx.ch wrote:
 Hello all,

 I'm searching/experimenting since hours, but I finally end up with nothing.

 I'm trying to use tal:repeat-Variables inside a php:-Condition, but
 everytime I do so, I got an error, that the variable is not defined.

 Here's my PHP-Array:
 ---
 $storeBoxes = array(
 array('nr'=3, 'name'='foo')
 );
 ---

 And my phptal:
 ---
    ul class=storeBoxes
        li tal:repeat=box storeBoxes class=storeBox
            strong tal:condition=php:${box/nr}  5
 tal:content=string:${box/name} ${repeat/box/number}
             gewählte Box #
            /strong
        /li
    /ul
 ---

 But all I get is, that nr is not defined (i tried to output it with
 tal:content and it worked...

 Can anyone help?

 greetings
 dominique

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal




-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Validation of XHTML - Solution

2009-05-18 Thread Tjerk Meesters
That's awesome :-)

A few more pointers:
1) it might be somewhat nicer to place phptal attributes in their own group:

!ENTITY % phptalattrs
 tal:define%Text;  #IMPLIED
  tal:condition %Text;  #IMPLIED
...
  tal:block %Text;  #IMPLIED
  
...
  !ENTITY % attrs %coreattrs; %i18n; %events; %phptalattrs;


2) add tal:block block element definitions (the gotcha here is that
inside tal:block you can also use stripped attributes, such as
condition or fill-slot without the tal: prefix

3) same for metal:block i guess? ;-)


Best,
  Tjerk

On Mon, May 18, 2009 at 3:12 PM, Guillaume Lecanu guilla...@lya.fr wrote:
 Le dimanche 17 mai 2009 à 20:32 +0800, Tjerk Meesters a écrit :


 It would be much easier if you could just add tal: and metal: inside the
 %coreattrs definition ;-)


 Hi everybody,


 With the help of Tjerk  Chris, I have created a XHTML STRICT 1.0 custom DTD
 for PHPTAL.
 I have attached it to this email.

 This will recognize all of the PHPTAL attributes in every XHTML tags.

 You can uses this DOCTYPE in your PHPTAL templates :
 !DOCTYPE html SYSTEM
 http://www.your-internet-web-site.com/path-to-your-dtd/xhtml1-strict-phptal.dtd;

 And of course, replace it by the good one at the fly for your final XHTML
 code.

 Hope this will help.



 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal





-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Validation of XHTML

2009-05-15 Thread Tjerk Meesters
It would be much easier if you could just add tal: and metal: inside
the %coreattrs definition ;-)


On Sun, Apr 12, 2009 at 11:16 PM,  php...@jakeman.plus.com wrote:
 To follow up my own posting, I've found it's possible to get the W3C
 validator to accept tal: and metal: attributes by using a DOCTYPE that
 points to a custom DTD. It's not ideal as you have to specify each
 combination of element and attribute that you have actually used. However it
 does work and a correct PHPTAL file is passed as fully valid. Once XHTML v2
 is available, maybe the validators will respect namespaces and we can
 specify tal: and metal: so that they are accepted.

 For notes on using custom DTDs, see WDG at
 http://htmlhelp.com/tools/validator/customdtd.html
 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal





-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] PHPTAL 1.2.0 alpha

2009-04-29 Thread Tjerk Meesters
Guess the __DIR__ constant came a bit too late then ;-)

On 4/29/09, Kornel Lesiński kor...@aardvarkmedia.co.uk wrote:
 On 29-04-2009 at 00:53:41 romtek rom...@gmail.com wrote:

 OK, I've given up on require() and changed it all to require_once().

 Is there ever a reason to use require() to include code (not text)?

 I hoped it would be faster than require_once, but it turned out that with
 relative paths the difference is insignificant.

 --
 regards, Kornel



 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Template storage in database?

2009-04-22 Thread Tjerk Meesters
Use setSource() of the phptal class to load from a string that you
fetch from your db

On 4/23/09, Jason La jaso...@gmail.com wrote:
 Hi,

 Is possible to store templates in a database instead of the file
 system, and how would I go about doing that?

 Thanks,
 Jason
 ===
 Jason La
 jaso...@gmail.com

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Dynamic defined slots

2009-02-06 Thread Tjerk Meesters
Wouldn't it make more sense to turn your define-slot's into use-macro
instead? ;-)


On 2/6/09, kaaposc kaap...@gmail.com wrote:
 Hello!

 Is there any way to define slots on the fly? Like this:
 tal:block repeat=item list metal:define-slot=sl_${item/name} /

 Currently looks like PHPTAL takes slot name as string without trying to
 parse. And of course PHP complaints about not finding such a variable
 item/name..


 Thanks,
 kaaposc

 ___
 PHPTAL mailing list
 PHPTAL@lists.motion-twin.com
 http://lists.motion-twin.com/mailman/listinfo/phptal



-- 
--
Tjerk

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


[PHPTAL] phptal and reflection

2008-03-10 Thread Tjerk Meesters
Hi,

After my recent recompilation of PHP, the logs were showing errors regarding
the reflection classes; however, the documentation never states its
dependency.

Tip: make sure that the ./configure line doesn't include
--disable-reflection during PHP installation.


Best,
  Jack
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal