added symlink dependencies for node_modules in Robo

This commit is contained in:
Jonathan Labreuille
2015-07-21 12:35:27 +02:00
parent 8137a30f46
commit fdddcbea14
7 changed files with 25 additions and 16 deletions

View File

@ -3,11 +3,21 @@ class RoboFile extends \Robo\Tasks {
function install() { function install() {
$this->_exec('./composer.phar install'); $this->_exec('./composer.phar install');
$this->_exec('npm install'); $this->_exec('npm install');
$this->symlinkDependencies();
} }
function update() { function update() {
$this->_exec('./composer.phar update'); $this->_exec('./composer.phar update');
$this->_exec('npm update'); $this->_exec('npm update');
$this->symlinkDependencies();
}
function symlinkDependencies() {
// handlebars
$this->_symlink(
__DIR__.'/node_modules/handlebars/dist/handlebars.min.js',
__DIR__.'/assets/js/handlebars/handlebars.min.js'
);
} }
function testUnit() { function testUnit() {

1
assets/js/handlebars/handlebars.min.js vendored Symbolic link
View File

@ -0,0 +1 @@
/Users/jonathan/work/namp2/node_modules/handlebars/dist/handlebars.min.js

View File

@ -43,8 +43,10 @@ class Initializer {
); );
// renderer: global variables // renderer: global variables
// $this->renderer->addGlobal('assets_url', $this->assets_url); $this->renderer->addExtension(new Renderer\Assets(array(
$this->renderer->addExtension(new Renderer\Assets($this->assets_url)); 'assets_url' => $this->assets_url,
'assets_path' => $this->assets_path
)));
register_activation_hook( register_activation_hook(
$this->file, $this->file,

View File

@ -3,10 +3,10 @@ namespace MailPoet\Renderer;
class Assets extends \Twig_Extension { class Assets extends \Twig_Extension {
public $assets_url; private $_globals;
public function __construct($assets_url) { public function __construct($globals) {
$this->assets_url = $assets_url; $this->_globals = $globals;
} }
public function getName() { public function getName() {
@ -14,9 +14,7 @@ class Assets extends \Twig_Extension {
} }
public function getGlobals() { public function getGlobals() {
return array( return $this->_globals;
'assets_url' => $this->assets_url
);
} }
public function getFunctions() { public function getFunctions() {
@ -42,7 +40,7 @@ class Assets extends \Twig_Extension {
$output[] = '<link $output[] = '<link
rel="stylesheet" rel="stylesheet"
type="text/css" type="text/css"
href="'.$this->assets_url.'/css/'.$stylesheet.'" href="'.$this->_globals['assets_url'].'/css/'.$stylesheet.'"
>'; >';
} }
@ -56,7 +54,7 @@ class Assets extends \Twig_Extension {
foreach($scripts as $script) { foreach($scripts as $script) {
$output[] = '<script $output[] = '<script
type="text/javascript" type="text/javascript"
src="'.$this->assets_url.'/js/'.$script.'" src="'.$this->_globals['assets_url'].'/js/'.$script.'"
></script>'; ></script>';
} }

View File

@ -16,9 +16,7 @@
<!-- javascripts --> <!-- javascripts -->
{{ javascript( {{ javascript(
'mailpoet_notice.js', 'notice.js',
'mailpoet_modal.js' 'modal.js',
)}} 'handlebars/handlebars.min.js'
)}}
<!-- todo: make it easier to load a dependency (loaded with Bower) -->
<!-- <script type="text/javascript" src="{{ assets_url }}/../bower_components/handlebars/handlebars.min.js"></script> -->