How to use getTemplatesDirectory method of html class

Best Atoum code snippet using html.getTemplatesDirectory

Template.php

Source:Template.php Github

copy

Full Screen

...19 public function __construct(Kirby $kirby, string $name, string $type = 'html', string $defaultType = 'html')20 {21 parent::__construct($name, $type, $defaultType);22 $this->kirby = $kirby;23 $this->templatesDirectory = $this->getTemplatesDirectory();24 $this->tempDirectory = $this->getTempDirectory();25 $this->checkTempDirectory();26 }27 /**28 * @param array $data29 * @return string30 * @throws \Kirby\Exception\Exception31 */32 public function render(array $data = []): string33 {34 if ($this->hasDefaultType() === true) {35 $latte = new LatteEngine;36 // extend latte37 $this->setCustomFilters();38 $this->setCustomFunctions();39 $this->setCustomMacros();40 $latte->setTempDirectory($this->tempDirectory);41 $html = $latte->renderToString($this->file(), $data);42 } else {43 try {44 $html = Tpl::load($this->file(), $data);45 } catch (Throwable $e) {46 throw new KirbyException($e->getMessage());47 }48 }49 return $html;50 }51 public function extension(): string52 {53 return 'latte';54 }55 public function file(): ?string56 {57 if ($this->hasDefaultType() === true) {58 try {59 // Try the default template in the default template directory.60 return F::realpath($this->getFilename(), $this->getTemplatesDirectory());61 } catch (Exception $e) {62 //63 }64 // Look for the default template provided by an extension.65 $path = $this->kirby->extension($this->store(), $this->name());66 if ($path !== null) {67 return $path;68 }69 }70 // disallow latte extension for content representation, for ex: /blog.latte71 if ($this->type() === 'latte') {72 return null;73 }74 $name = $this->name() . '.' . $this->type();75 try {76 // Try the template with type extension in the default template directory.77 return F::realpath($this->getFilename($name), $this->getTemplatesDirectory());78 } catch (Exception $e) {79 // Look for the template with type extension provided by an extension.80 // This might be null if the template does not exist.81 $fallback = $this->kirby->extension($this->store(), $name);82 // fallback null with provided extension, set header as default type instead extension83 if ($fallback === null) {84 $this->kirby->response()->type($this->defaultType());85 }86 return $fallback;87 }88 }89 public function getFilename(string $name = null): string90 {91 if ($name === null) {92 return $this->getTemplatesDirectory() . '/' . $this->name() . '.' . $this->extension();93 }94 if ($this->hasDefaultType() === true) {95 return $this->getTemplatesDirectory() . '/' . $this->name() . '.' . $this->extension();96 }97 return $this->getTemplatesDirectory() . '/' . $name . '.' . $this->extension();98 }99 protected function getTemplatesDirectory(): string100 {101 if ($this->templatesDirectory !== null) {102 return $this->templatesDirectory;103 }104 $path = option('afbora.kirby-latte.templatesDirectory');105 if ($path !== null && is_dir($path) === true) {106 if (is_callable($path)) {107 return $path();108 }109 $path = $this->kirby->root() . '/' . $path;110 }111 if (empty($path) === true) {112 return $this->root();113 }...

Full Screen

Full Screen

TwigTemplate.php

Source:TwigTemplate.php Github

copy

Full Screen

...23 public function __construct( $template,$response )24 {25 parent::__construct($template, $response );26 $this->twigloader = new TwigLoader();27 $tdd = $this->getTemplatesDirectory();28 if( is_array($tdd) ){29 foreach ($tdd as $item) {30 $this->twigloader->addPath($item);31 }32 }else{33 $this->twigloader->addPath($tdd);34 }35 $this->twigloader->addPath( Environment::$ROOT."/applications");36 $twigOptions = [37 'cache' => $this->getCacheDir().'/cache',38 'auto_reload' => false39 ];40 41 42 43 if( !\applications\settings\entities\Setting::getValueOf("cache_templates",false) ){44 $twigOptions['auto_reload'] = true;45 $twigOptions['debug'] = true;46 }47 48 $this->twig = new \Twig_Environment($this->twigloader,$twigOptions);49 if(Environment::is(Environment::DEV)) {50 $this->twig->addExtension(new \Twig_Extension_Debug());51 }52 $this->twig->addExtension(new Twig_Extension_StringLoader());53 $this->twig->addFilter( new \Twig_SimpleFilter('cast_to_array', function ($stdClassObject) {54 $response = array();55 foreach ($stdClassObject as $key => $value) {56 $response[] = array($key, $value);57 }58 return $response;59 }));60 $this->twig->addFilter( new \Twig_SimpleFilter('price', function ( $p ) {61 return Response::formatPrice($p);62 }));63 $this->twig->addTest(new \Twig_Test('string',function($value){64 return is_string($value);65 }));66 /*67 $twigFunction = new \Twig_SimpleFunction('CLCatalog', function($method,$var) {68 return \models\CL\CLCatalog::$method($var);69 });70 $twig->addFunction($twigFunction);71 */72 $this->twig->addFunction(new \Twig_Function("t",function(){73 return func_get_args()[0];74 }));75 }76 public function exists($template)77 {78 return $this->twigloader->exists($template);79 }80 public function render()81 {82 $ex = explode("/",$this->template);83 if (!$this->response || !$this->template) return false;84 if( isset($this->response['data']) && is_array($this->response['data']) && isset($this->response['data']['type']) && $this->response['data']['type']=="redirect"){85 Response::go($this->response['data']['to']);86 }87 $pagina = false;88 $query = Request::getQuery();89 if ($query == "") $query = "/";90 $pagina = Pagina::findRawBySlug($query);91 if($pagina)92 $this->response['meta'] = $pagina->getMeta();93 $this->response["current_url"] = Request::getCurrentUrl();94 return $this->twig->render(95 $this->template.".twig",96 $this->response97 );98 }99 static function renderFunction($callable,$args = []){100 $result = call_user_func_array($callable,$args);101 if( is_string($result)) return $result;102 list($template,$response) = $result;103 $r = new \Twig_Markup( Response::getNewFrontendTemplate( $template,$response)->render() , "utf-8" );104 return $r;105 }106 public function addFunction( $name, $callable ){107 $this->twig->addFunction(new \Twig_Function($name,function() use ($callable){108 $args = func_get_args();109 return static::renderFunction($callable,$args);110 } ,111 array(112 'pre_escape' => 'html',113 'is_safe' => array('html')114 )115 ));116 }117 abstract function getTemplatesDirectory();118 function getCacheDir(){119 return (is_array($this->getTemplatesDirectory()) ? $this->getTemplatesDirectory()[0] : $this->getTemplatesDirectory())."/cache";120 }121}...

Full Screen

Full Screen

Renderer.php

Source:Renderer.php Github

copy

Full Screen

...54 'lang' => array(55 'locale' => $_SESSION['locale'],56 'iso' => $_SESSION['isoLang']57 ),58 'templatesDirectory' => $this->getTemplatesDirectory()59 );60 // Adds extra helpers to the View object61 if (isset($viewHelpers) && is_array($viewHelpers)) {62 foreach ($viewHelpers as $v) {63 $View->addHelper($v);64 }65 }66 // Gets header67 $htmlHeader = '';68 if (self::$_options['header']) {69 ob_start();70 require $this->getTemplatesDirectory() . '/' . self::$_options['header'];71 $htmlHeader = ob_get_clean();72 }73 // Gets content74 ob_start();75 require $this->getTemplatesDirectory() . "/{$template}";76 $htmlContent = ob_get_clean();77 // Gets footer78 $htmlFooter = '';79 if (self::$_options['footer']) {80 ob_start();81 require $this->getTemplatesDirectory() . '/' . self::$_options['footer'];82 $htmlFooter = ob_get_clean();83 }84 // Gets full layout85 if (self::$_options['layout']) {86 ob_start();87 require $this->getTemplatesDirectory() . '/' . self::$_options['layout'];88 $res = ob_get_clean();89 } else {90 $res = $htmlContent;91 }92 return $res;93 }94 ////95 // Setters from now on.96 ////97 public static function setLayout($name)98 {99 self::$_options['layout'] = $name;100 }101 public static function setHeader($name)...

Full Screen

Full Screen

getTemplatesDirectory

Using AI Code Generation

copy

Full Screen

1echo $html->getTemplatesDirectory();2echo $html->getTemplatesDirectory();3echo $html->getTemplatesDirectory();4{5 protected static $templatesDirectory = 'templates';6 public function getTemplatesDirectory()7 {8 return self::$templatesDirectory;9 }10}11echo $html->getTemplatesDirectory();

Full Screen

Full Screen

getTemplatesDirectory

Using AI Code Generation

copy

Full Screen

1echo $html->getTemplatesDirectory();2echo $html->getTemplatesDirectory();3echo $html->getTemplatesDirectory();4echo $html->getTemplatesDirectory();5echo $html->getTemplatesDirectory();6echo $html->getTemplatesDirectory();7echo $html->getTemplatesDirectory();8echo $html->getTemplatesDirectory();9echo $html->getTemplatesDirectory();10echo $html->getTemplatesDirectory();11echo $html->getTemplatesDirectory();12echo $html->getTemplatesDirectory();13echo $html->getTemplatesDirectory();14echo $html->getTemplatesDirectory();15echo $html->getTemplatesDirectory();16echo $html->getTemplatesDirectory();17echo $html->getTemplatesDirectory();18echo $html->getTemplatesDirectory();19echo $html->getTemplatesDirectory();

Full Screen

Full Screen

getTemplatesDirectory

Using AI Code Generation

copy

Full Screen

1$dir = $html->getTemplatesDirectory();2echo $dir;3$dir = $html->getTemplatesDirectory();4echo $dir;5$dir = $html->getTemplatesDirectory();6echo $dir;7$dir = $html->getTemplatesDirectory();8echo $dir;9$dir = $html->getTemplatesDirectory();

Full Screen

Full Screen

getTemplatesDirectory

Using AI Code Generation

copy

Full Screen

1require_once('html.class.php');2$html = new html();3echo $html->getTemplatesDirectory();4require_once('html.class.php');5$html = new html();6echo $html->getTemplatesDirectory();7require_once('html.class.php');8$html = new html();9echo $html->getTemplatesDirectory();10{11 public function getTemplatesDirectory()12 {13 return dirname(__FILE__) . '/templates/';14 }15}16require_once('html.class.php');17$html = new html();18echo $html->getTemplatesDirectory();19require_once('html.class.php');20$html = new html();21echo $html->getTemplatesDirectory();22require_once('html.class.php');23$html = new html();24echo $html->getTemplatesDirectory();25Why we are using dirname() function?

Full Screen

Full Screen

getTemplatesDirectory

Using AI Code Generation

copy

Full Screen

1require_once 'HTML/Template/IT.php';2$tpl = new HTML_Template_IT();3$tpl->loadTemplatefile('1.tpl');4echo $tpl->getTemplatesDirectory();5require_once 'HTML/Template/IT.php';6$tpl = new HTML_Template_IT();7$tpl->setRoot('templates');8$tpl->loadTemplatefile('2.tpl');9echo $tpl->get();10require_once 'HTML/Template/IT.php';11$tpl = new HTML_Template_IT();12$tpl->setTemplateRoot('templates');13$tpl->loadTemplatefile('3.tpl');14echo $tpl->get();15require_once 'HTML/Template/IT.php';16$tpl = new HTML_Template_IT();17$tpl->setTemplateRoot('templates');18$tpl->loadTemplatefile('4.tpl');19echo $tpl->get();20require_once 'HTML/Template/IT.php';21$tpl = new HTML_Template_IT();22$tpl->setTemplateRoot('templates');23$tpl->loadTemplatefile('5.tpl');24echo $tpl->get();25require_once 'HTML/Template/IT.php';26$tpl = new HTML_Template_IT();27$tpl->setTemplateRoot('templates');28$tpl->loadTemplatefile('6.tpl');29echo $tpl->get();30require_once 'HTML/Template/IT.php';31$tpl = new HTML_Template_IT();32$tpl->setTemplateRoot('templates');33$tpl->loadTemplatefile('7.tpl');34echo $tpl->get();

Full Screen

Full Screen

getTemplatesDirectory

Using AI Code Generation

copy

Full Screen

1$templates_dir = $html->getTemplatesDirectory();2$template_file = $html->getTemplate('template1');3$template_file = $html->getTemplate('template2');4$template_file = $html->getTemplate('template3');5$template_file = $html->getTemplate('template4');6$template_file = $html->getTemplate('template5');7$template_file = $html->getTemplate('template6');8$template_file = $html->getTemplate('template7');9$template_file = $html->getTemplate('template8');10$template_file = $html->getTemplate('template9');11$template_file = $html->getTemplate('template10');12$template_file = $html->getTemplate('template11');13$template_file = $html->getTemplate('template12');14$template_file = $html->getTemplate('template13');15$template_file = $html->getTemplate('template14');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful