Closed ryan-mahoney closed 10 years ago
I have made these changes in my fork and have done some cursory testing. Please let me know what you think. I know it's not really a big deal... but I think it makes the code more "modern" feeling.
Also, the current composer.json file makes it seems as if there is a namespace, when in fact in the current code there is not.
You can see this in my fork: https://github.com/virtuecenter/handlebars.php
Thanks, Ryan
I'll keep this issue open (if you don't mind), until I find some free time to:
Sound good, thanks so much
+1. Ditch 5.2.x already.
for the record:
Hopefully, I'll start writing tests in a few days.
I had trouble importing Handlebars after the introduction of the namespace. I think I don't understand well how namespaces work, but this is how I eventually got it to work inside my CakePHP application. Specifically, I did not write use Handlebars\Handlebars
.
class PageController extends AppController {
public function show($id) {
require_once current(App::path('Vendor')) . '/Handlebars/Autoloader.php';
Handlebars\Autoloader::register();
$hdlbars = new Handlebars\Handlebars();
...
$hdlbars->render($template, $recordData);
}
}
....
Whenever I tried to use
the namespace, I got errors (class Autoloader not found
) or warnings (The use statement with non-compound name 'Handlebars' has no effect
).
@boukeversteegh if you're using use
keyword for loading Autoloader, that's normal (there's no autoloader yet to autoload it) unless you use composer and in that case, you don't need to use Autoloader at all, composer takes care of autoloading. if you've something like this
$h = new Handlebars\Handlebars;
you can replace it with
use Handlebars\Handlebars;
$h = new Handlebars
which is useful when you make lots of instances.
thanks to @fzerorubigd, now we've tests setup. still we need to add more test, but I'm gonna close this issue.
@everplays great work. Looking forward to checking this out!
Minor recommendations:
Then to use the class, we would do:
use Handlebars\Handlebars;
Handlebars->template($template, $data);