PHP Class Bolt\Twig\Handler\HtmlHandler

Show file Open project: bolt/bolt Class Usage Examples

Public Methods

Method Description
__construct ( Silex\Application $app )
decorateTT ( string $str ) : string Transforms plain text to HTML
editable ( string $html, Content $content, string $field, boolean $safe ) : string Makes a piece of HTML editable.
htmlLang ( ) : string Returns the language value for in tags where the language attribute is required. The underscore '_' in the locale will be replaced with a hyphen '-'.
isMobileClient ( ) : boolean Check if the page is viewed on a mobile device.
link ( string $location, string $label = '[link]' ) : string Create an HTML link to a given URL or contenttype/slug pair.
markdown ( string $content ) : string Formats the given string as Markdown in HTML.
menu ( Twig_Environment $env, string $identifier = '', string $template = '_sub_menu.twig', array $params = [], boolean $safe ) : string | null Output a menu.
shy ( string $str ) : string Add 'soft hyphens' ­ to a string, so that it won't break layout in HTML when using strings without spaces or dashes.
twig ( $snippet, array $extravars = [] ) : string Formats the given string as Twig in HTML.

Method Details

__construct() public method

public __construct ( Silex\Application $app )
$app Silex\Application

decorateTT() public method

Transforms plain text to HTML
See also: Bolt\Helpers\Html::decorateTT()
public decorateTT ( string $str ) : string
$str string
return string

editable() public method

Makes a piece of HTML editable.
public editable ( string $html, Content $content, string $field, boolean $safe ) : string
$html string The HTML to be editable
$content Bolt\Legacy\Content The actual content
$field string
$safe boolean
return string

htmlLang() public method

Returns the language value for in tags where the language attribute is required. The underscore '_' in the locale will be replaced with a hyphen '-'.
public htmlLang ( ) : string
return string

isMobileClient() public method

Check if the page is viewed on a mobile device.
public isMobileClient ( ) : boolean
return boolean

markdown() public method

Formats the given string as Markdown in HTML.
public markdown ( string $content ) : string
$content string
return string Markdown output

menu() public method

Output a menu.
public menu ( Twig_Environment $env, string $identifier = '', string $template = '_sub_menu.twig', array $params = [], boolean $safe ) : string | null
$env Twig_Environment
$identifier string Identifier for a particular menu
$template string The template to use.
$params array Extra parameters to pass on to the menu template.
$safe boolean
return string | null

shy() public method

Add 'soft hyphens' ­ to a string, so that it won't break layout in HTML when using strings without spaces or dashes.
public shy ( string $str ) : string
$str string
return string

twig() public method

Note: this is partially duplicating the template_from_string functionality: http://twig.sensiolabs.org/doc/functions/template_from_string.html We can't use that functionality though, since it requires the Twig_Extension_StringLoader() extension. If we would use that, when instantiating Twig, it screws up the rendering: Every template that has a filename that doesn't exist will be rendered as literal string. This _really_ messes up the 'cascading rendering' of our theme templates.
public twig ( $snippet, array $extravars = [] ) : string
$snippet
$extravars array
return string Twig output