feulf / raintpl3

The easiest Template Engine for PHP
https://feulf.github.io/raintpl
258 stars 57 forks source link

Patches for split_parser branch - fixed one bug in include tag and added include_path #118

Open keskad opened 11 years ago

keskad commented 11 years ago

Hello.

RainTPL just stopped working with include tags. So I fixed the problem and added new option "include_path" that will allow searching for template to include in many diffirent paths. It will not slow down template engine as it's only doing once (when template is going to be compiled).

I will add also two configuration options "force_compile" and "dont_compile". The first one will be for debugging purposes (I have save a template file everytime I want to debug parser... it's annoying) and the second one will allow compiling templates from crontab.

@edit Removed "force_compile" as there is already "debug" option that provides same feature. Added "allow_compile" and "allow_compile_once" - with True values by default.

prisis commented 10 years ago

how can i include a full path?

because if i use multi tpl_dir and dont have the same folders

something like that

Modul/Content/Tpl/content.html

and my base folder

Themes/public/desktop/test/index.html

i need content from folder A in index from folder B, when i use {include = "Content/Tpl/content"} i get a error that TPL can find that template

feulf commented 10 years ago

I'll work on this issue, thanks for reporting it.

On Thu, Oct 24, 2013 at 4:50 PM, prisis notifications@github.com wrote:

how can i include a full path?

because if i use multi tpl_dir and dont have the same folders

something like that

Modul/Content/Tpl/content.html

and my base folder

Themes/public/desktop/test/index.html

i need content from folder A in index from folder B, when i use {include = "Content/Tpl/content"} i get a error that TPL can find that template

— Reply to this email directly or view it on GitHubhttps://github.com/rainphp/raintpl3/pull/118#issuecomment-27028618 .

prisis commented 10 years ago

Hi @rainphp , did you find a solution for me problem?, im trying my self but i dont have any luck -.-

feulf commented 10 years ago

Hey @prisis, I've implemented the absolute path in this pull request. This will fix your problem: https://github.com/rainphp/raintpl3/pull/128

Let me know if works and I'll merge the pull request.

keskad commented 10 years ago

I will take a look at this code today and figure out how to solve your problem.

prisis commented 10 years ago

i will take a look too :), the best opinion were if you can set more folders and loop through all folder if the tpl exist, but i will test you code,

example: 
"include_path" => array(
                  self::$ModulTemplateDir,
               ),
"tpl_dir"  => array(
  self::$TemplateDir . DS,
  ),

{include="Content/Tpl/content'"} => PUBPATH . 'Modul' . DS . 'Content/Tpl/content.html'

{include="footer"} => PUBPATH . 'Themes/Admin/Test/footer.html'
feulf commented 10 years ago

@prisis I'm against adding more configurations or features, this will work for you:

'tpl_dir' => array(
    self::$TemplateDir . DS,
    self::$ModulTemplateDir,
);
{include="Content/Tpl/content"}
{include="footer"}