cretz / dust-php Goto Github PK
View Code? Open in Web Editor NEWPowerful PHP templating engine based off of Dust JS
Home Page: http://cretz.github.com/dust-php
License: MIT License
Powerful PHP templating engine based off of Dust JS
Home Page: http://cretz.github.com/dust-php
License: MIT License
I am trying to do the following:
{+footer}
{>"../partials/footer" /}
{/footer}
©2014 fog.im Team
...but if I render it, it doesn't get included.
When I put it directly into the block like this:
{+footer}
©2014 fog.im Team
{/footer}
...it works. Is this a bug or am I doing something wrong?
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.
The exception "Unable to find helper" does not specify which helper cannot be found.
How to install this project without Composer?
Composer is so much loaded with bugs, using composer is perfect way to smash any project...
See this: https://github.com/composer/composer/issues
I happened to use the word "join" in some text that I was passing to renderTemplate()
. This resulted in the following error:
Warning: join(): Invalid arguments passed in /path/to/vendor/dust-php/dust-php/src/Dust/Evaluate/Evaluator.php on line 342
This seems like it is probably a very bad security vulnerability.
Is anyone still maintaining this project?
According to the docs, filters are created as callable functions
$dust->filters['striptags'] = function ($value) {
//not a string, nothing to do
if (!is_string($value)) {
return $value;
}
//otherwise strip the tags
return strip_tags($value);
}
Which results in Call to undefined method Closure::apply()
I had to create a subclass of \Dust\Filter\Filter
to get it to work.
class DateFilter implements \Dust\Filter\Filter {
public function apply($value) {
return date('d/m/Y', (new DateTime($value))->getTimestamp());
}
}
I have basically abandoned this project since I no longer use PHP regularly. If anyone wants to fork it (or just build a different dust-php project), please do. Let me know and I'll update the readme pointing there.
Hello,
I am looking forward to use your beautiful classes, but I don't know anything about your pratphall.
Would it be possible to generate "standard php" set of classes?
I tried using:
require("dust-php/Dust.php");
$dust = new Dust\Dust();
$dust->compile($anything);
But that lead to "Class 'Dust\Parse\Parser' not found".
Could you help me?
Thanks in advance
Hello!
I do not understand how i can use list as param in helper?
So i have some helper
ex:
$this->_dust->helpers['print_r'] = function...
~~template.dust~~
{@print_r dump=... /}
How i can transmit into the dump list|array ?
dump[1]="100"
dump["key"]="100"
dump[]="100"
dump.key="100"
dump=["key":data.reference]
I try it all. Please help. I cant find any ex. about it.
$ git clone https://github.com/cretz/dust-php.git && cd dust-php
Cloning into dust-php...
remote: Counting objects: 246, done.
remote: Compressing objects: 100% (149/149), done.
remote: Total 246 (delta 93), reused 244 (delta 91)
Receiving objects: 100% (246/246), 170.70 KiB, done.
Resolving deltas: 100% (93/93), done.
$ npm install
info trying registry request attempt 1 at 12:00:36
http GET https://registry.npmjs.org/pratphall
info trying registry request attempt 1 at 12:00:36
http GET https://registry.npmjs.org/fs-extra
info trying registry request attempt 1 at 12:00:36
http GET https://registry.npmjs.org/dustjs-linkedin/1.2.0
info trying registry request attempt 1 at 12:00:36
http GET https://registry.npmjs.org/jake
http 304 https://registry.npmjs.org/fs-extra
http 304 https://registry.npmjs.org/dustjs-linkedin/1.2.0
http 304 https://registry.npmjs.org/pratphall
npm http GET https://registry.npmjs.org/dustjs-linkedin/-/dustjs-linkedin-1.2.0.tgz
http 304 https://registry.npmjs.org/jake
npm http 200 https://registry.npmjs.org/dustjs-linkedin/-/dustjs-linkedin-1.2.0.tgz
info trying registry request attempt 1 at 12:00:40
http GET https://registry.npmjs.org/jsonfile
info trying registry request attempt 1 at 12:00:40
http GET https://registry.npmjs.org/ncp
info trying registry request attempt 1 at 12:00:40
http GET https://registry.npmjs.org/rimraf
info trying registry request attempt 1 at 12:00:40
http GET https://registry.npmjs.org/mkdirp
info trying registry request attempt 1 at 12:00:40
http GET https://registry.npmjs.org/utilities
info trying registry request attempt 1 at 12:00:40
http GET https://registry.npmjs.org/minimatch
http 304 https://registry.npmjs.org/mkdirp
http 304 https://registry.npmjs.org/rimraf
http 304 https://registry.npmjs.org/ncp
http 304 https://registry.npmjs.org/jsonfile
http 304 https://registry.npmjs.org/utilities
info trying registry request attempt 1 at 12:00:41
http GET https://registry.npmjs.org/graceful-fs
http 304 https://registry.npmjs.org/minimatch
info trying registry request attempt 1 at 12:00:41
http GET https://registry.npmjs.org/lru-cache
info trying registry request attempt 1 at 12:00:41
http GET https://registry.npmjs.org/sigmund
http 304 https://registry.npmjs.org/graceful-fs
http 304 https://registry.npmjs.org/lru-cache
http 304 https://registry.npmjs.org/sigmund
[email protected] node_modules/dustjs-linkedin
[email protected] node_modules/fs-extra
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])
[email protected] node_modules/jake
├── [email protected]
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/pratphall
$ ./node_modules/.bin/jake build --trace
Recreating src and tests folders
Compiling with Pratphall
path.js:313
throw new TypeError('Arguments to path.resolve must be strings');
^
TypeError: Arguments to path.resolve must be strings
at Object.exports.resolve [as resolvePath] (path.js:313:15)
at addUnitAndReferences (/root/Development/dust-php/node_modules/pratphall/bin/ppc.js:23776:41)
at Array.forEach (native)
at Compiler.compile (/root/Development/dust-php/node_modules/pratphall/bin/ppc.js:23805:19)
at Compiler.run (/root/Development/dust-php/node_modules/pratphall/bin/ppc.js:24129:33)
at CommandLineRunner.run (/root/Development/dust-php/node_modules/pratphall/bin/ppc.js:28049:26)
at Pratphall (/root/Development/dust-php/node_modules/pratphall/bin/ppc.js:28057:29)
at Object.<anonymous> (/root/Development/dust-php/node_modules/pratphall/bin/ppc.js:28058:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
jake aborted.
ode_modules/pratphall/bin/ppc.js:23776:41)
at Array.forEach (native)
at Compiler.compile (/root/Development/dust-php
ode_modules/pratphall/bin/ppc.js:23805:19)
at Compiler.run (/root/Development/dust-php
ode_modules/pratphall/bin/ppc.js:24129:33)
at CommandLineRunner.run (/root/Development/dust-php
ode_modules/pratphall/bin/ppc.js:28049:26)
at Pratphall (/root/Development/dust-php
ode_modules/pratphall/bin/ppc.js:28057:29)
at Object.<anonymous> (/root/Development/dust-php
ode_modules/pratphall/bin/ppc.js:28058:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
$ node --version
v0.10.13
This error message seems to be related to an API break in Node 0.10, is there a way to fix this?
What feature of PHP 5.4 are you using in Dust PHP besides the short array syntax? At a cursory glance, I can't really see anything except for that which would require 5.4, but I may be missing something.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.