public static function template($name)
    {
        $template = null;

        //
        // It's a template name or template contents?
        //
        if (preg_match('/^[A-Za-z0-9_\.\-\/]+\.html$/', $name)) {
            // It's a template name!
            $template = static::get(self::TYPE_TEMPLATE, $name);

            if (!$template) {
                $fallback_template_path = shared_storage_dir() . '/default/templates/' . $name;
                // try to retrieve local fallback template
                if (!file_exists($fallback_template_path)) {
                    throw new Exceptions\MethodFailureException("Template not found: '{$name}'. Please run `hook generate:template {$name}` to generate one.");
                }

                // use local template if can't find
                $template = new static(array(
                    'type' => self::TYPE_TEMPLATE,
                    'code' => file_get_contents($fallback_template_path),
                    'name' => $name
                ));
            }
        }

        if (!$template) {
            $template = new static(array(
                'type' => self::TYPE_TEMPLATE,
                'code' => $name,
                'name' => 'inline-template.html'
            ));
        }

        return $template;
    }
public static function template($name)
    {
        $template = null;

        //
        // It's a template name or template contents?
        //
        if (preg_match('/^[A-Za-z0-9_\.\-\/]+\.html$/', $name)) {
            // It's a template name!
            $template = static::get(self::TYPE_TEMPLATE, $name);

            if (!$template) {
                $fallback_template_path = shared_storage_dir() . '/default/templates/' . $name;
                // try to retrieve local fallback template
                if (!file_exists($fallback_template_path)) {
                    throw new Exceptions\MethodFailureException("Template not found: '{$name}'. Please run `hook generate:template {$name}` to generate one.");
                }

                // use local template if can't find
                $template = new static(array(
                    'type' => self::TYPE_TEMPLATE,
                    'code' => file_get_contents($fallback_template_path),
                    'name' => $name
                ));
            }
        }

        if (!$template) {
            $template = new static(array(
                'type' => self::TYPE_TEMPLATE,
                'code' => $name,
                'name' => 'inline-template.html'
            ));
        }

        return $template;
    }
public static function template ( $ name ) { $ template = null ; // // It's a template name or template contents? // if ( preg_match ( '/^[A-Za-z0-9_\.\-\/]+\.html$/' , $ name ) ) { // It's a template name! $ template = static :: get ( self :: TYPE_TEMPLATE , $ name ) ; if ( ! $ template ) { $ fallback_template_path = shared_storage_dir ( ) . '/default/templates/' . $ name ; // try to retrieve local fallback template if ( ! file_exists ( $ fallback_template_path ) ) { throw new Exceptions \ MethodFailureException ( "Template not found: '{$name}'. Please run `hook generate:template {$name}` to generate one." ) ; } // use local template if can't find $ template = new static ( array ( 'type' => self :: TYPE_TEMPLATE , 'code' => file_get_contents ( $ fallback_template_path ) , 'name' => $ name ) ) ; } } if ( ! $ template ) { $ template = new static ( array ( 'type' => self :: TYPE_TEMPLATE , 'code' => $ name , 'name' => 'inline-template.html' ) ) ; } return $ template ; }
Get a template module instance, trying to fallback to a general template
@param string name
@return Module
Get a template module instance trying to fallback to a general template