cretz / dust-php

Powerful PHP templating engine based off of Dust JS
http://cretz.github.com/dust-php
MIT License
67 stars 19 forks source link

value=current wrongly replaced #2

Open stvogel opened 11 years ago

stvogel commented 11 years ago

the following produces: $template = $dust->compile('Title:{title}'); $dust->renderTemplate($template, array('title' => 'current'));

'Title: Dust\Evaluate\Evaluator'

I suppose that's on purpose, but it differs from the dust.js version

Otherwise thanks for your port to php. I would really like to see a port to PHP 5.3 especially because the code really only uses the array-initialization of PHP 5.4.

cretz commented 11 years ago

I will look into this at some point. The 5.4 requirement is explained in issue #1. I am likely going to come back to this project and rewrite it all in native PHP but lately I have not put any effort into this project.

stvogel commented 11 years ago

I've adapted the generated PHP-Code, so that it works with 5.3. It was quite easy. Thanks for looking into the issue. You're right. It might be worth a thought to rewrite it in native PHP. The source code is a bit ... blown up :-)

prewk commented 10 years ago

Other values causing issues: link, unlink "Warning: unlink() expects parameter 1 to be string, object given in /home/oskar/www/library/dust-php/Evaluate/Evaluator.php on line 342"

Can this be hack-fixed in some way until you update it with a better solution? (So that parameters always remain parameters)

Thanks a lot, btw!

ekkl commented 10 years ago

I use php 5.5 and i have the sаme problem.

bash commented 9 years ago

I've found a solution for this problem:

Dust/Evaluate/Evaluator.php:
public function normalizeResolved(Context $ctx, $resolved, Chunk $chunk, Ast\Section $section = null) {
        $handledSpecial = true;

        while ($handledSpecial) {
            if (is_callable($resolved) && !is_string($resolved)) {
            ...