public function __call($method, $arguments) { $extensions = array(".html", ".md", ".markdown", ".textile"); $html = null; foreach ($extensions as $extension) { $full_src = Path::assemble(BASE_PATH, Config::getCurrentThemePath(), 'partials', ltrim($method . $extension, '/')); if (File::exists($full_src)) { // Merge additional variables passed as parameters Statamic_View::$_dataStore = $arguments + Statamic_View::$_dataStore; if ($this->fetchParam('use_context', false, false, true, false)) { $html = Parse::contextualTemplate(File::get($full_src), Statamic_View::$_dataStore, $this->context, 'Statamic_View::callback'); } else { $html = Parse::template(File::get($full_src), Statamic_View::$_dataStore, 'Statamic_View::callback'); } // parse contents if needed if ($extension == ".md" || $extension == ".markdown") { $html = Parse::markdown($html); } elseif ($extension == ".textile") { $html = Parse::textile($html); } } } if (Config::get('enable_smartypants', TRUE)) { $html = Parse::smartypants($html); } return $html; }
public function partial() { $src = $this->fetchParam('src', null, null, false, false); if ($src) { $src .= ".html"; $partial_path = $this->theme_root . 'partials/' . ltrim($src, '/'); if (File::exists($partial_path)) { Statamic_View::$_dataStore = array_merge(Statamic_View::$_dataStore, $this->attributes); return Parse::template(file_get_contents($partial_path), Statamic_View::$_dataStore, 'Statamic_View::callback'); } } return null; }
public function partial() { $start = time(); $src = $this->fetchParam('src', null, null, false, false); $extensions = array(".html", ".md", ".markdown", ".textile"); $html = null; // measurement $hash = Debug::markStart('partials', $src, $start); Debug::increment('partials', $src); if ($src) { foreach ($extensions as $extension) { $full_src = Path::assemble(BASE_PATH, $this->theme_root, 'partials', ltrim($src . $extension, '/')); if (File::exists($full_src)) { Statamic_View::$_dataStore = $this->attributes + Statamic_View::$_dataStore; if ($this->fetchParam('use_context', false, false, true, false)) { // to use context, we only want to pass the attributes as // the current data, as those will override into the context // set of data; if we were to include all of ::$_dataStore, // we run into the issue where all of the global-level variables // are overriding variables in context, when the variables in // context are more accurate scope-wise at this point in the parse $html = Parse::contextualTemplate(file_get_contents($full_src), $this->attributes, $this->context, array('statamic_view', 'callback'), true); } else { $html = Parse::template(file_get_contents($full_src), Statamic_View::$_dataStore); } // parse contents if needed if ($extension == ".md" || $extension == ".markdown") { $html = Parse::markdown($html); } elseif ($extension == ".textile") { $html = Parse::textile($html); } } } if (Config::get('enable_smartypants', TRUE)) { $html = Parse::smartypants($html); } } Debug::markEnd($hash); return $html; }
/** * Prepend any new data into this view's data store * * @param $data array Array of data to merge * @return void */ public static function prependNewData($data) { foreach ($data as $key => $item) { if (is_object($item)) { unset($data[$key]); } } Statamic_View::$_dataStore = Statamic_View::$_dataStore + $data; }
/** * _render_layout * Renders the page * * @param string $_html HTML of the template to use * @param string $template_type Content type of the template * @return string */ public function _render_layout($_html, $template_type = 'html') { if (self::$_layout != '') { $this->data['layout_content'] = $_html; $layout_path = $this->getTemplatesDirectory() . '/' . ltrim(self::$_layout, '/'); if ($template_type == 'html') { if (!file_exists($layout_path . ".html")) { Log::fatal("Can't find the specified theme", 'template'); return '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">We can\'t find your theme files. Please check your settings.'; } Statamic_View::$_dataStore = array_merge(Statamic_View::$_dataStore, $this->data); $html = $this->parser->parse(file_get_contents($layout_path . ".html"), Statamic_View::$_dataStore, array($this, 'callback'), true); $html = Lex\Parser::injectNoparse($html); } else { extract($this->data); ob_start(); require $layout_path . ".php"; $html = ob_get_clean(); } return $html; } return $_html; }
/** * Merges any new data into this view's data store * * @param $data array Array of data to merge * @return void */ function mergeNewData($data) { foreach ($data as $key => $item) { if (is_object($item)) { unset($data[$key]); } } Statamic_View::$_dataStore = $data + Statamic_View::$_dataStore; }