Closed alexandru-elisei closed 8 years ago
I understand what you are doing. You are expecting that each template that requires the config.php file to overwrite the path_to_config block like this:
{{$ path_to_config }}{{{ self.pathtoconfig }}}{{/ path_to_config }}
I find this cumbersome. The path to the config.php file is generated for each file in the function manager::prepare_file_skeleton(), why not include it directly?
I think I tried to do it directly. But it did not work for me, given how blocks work in Mustache (https://github.com/bobthecow/mustache.php/wiki/BLOCKS-pragma). If you find a way how to nicely inject variables values into the block without this assignment-in-the-middle, I'll be happy to be taught.
It worked for me. I simply used the self.pathtoconfig variable.
Hmm, interesting. So I guess we can remove path_to_config
computation completely from all the templates that use the boilerplate?
And also use it in the {{# is_cli_file }}
section, I suppose.
I've tested it by using php_cli_file skel class for one the features, it generates the path to config.php correctly.
In classes/local/util/manager.php, at line 193:
$data['self']['pathtoconfig'] = "__DIR__.'/".str_repeat('../', substr_count($data['self']['relpath'], '/') - 1)."config.php'";
In skel/common/boilerplate_php.mustache, at line 46:
{{^ is_moodle_internal }}require({{$ path_to_config }}__DIR__.'/../../config.php'{{/ path_to_config}});{{/ is_moodle_internal }}
You're using two different names for path to config.Waiting the result of #19 to propose a fix.