You are here

public static function HamlHelpers::html_attrs in Sassy 7

* Returns an array containing default assignments for the xmlns, lang, and * xml:lang attributes of the html element. * This helper method is for use in the html element only. * * Examples:<br/> * %html(html_attrs())<br/> * produces<br/> * <html lang="en-us" xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml"> * * %html(html_attrs('en-gb'))<br/> * produces<br/> * <html lang="en-gb" xml:lang="en-gb" xmlns="http://www.w3.org/1999/xhtml"> * * %html(html_attrs('en-gb', false))<br/> * produces<br/> * <html xml:lang="en-gb" xmlns="http://www.w3.org/1999/xhtml"> * * Although handled in HamlParser, the notes below are here for completeness.<br/> * Other attributes are defined as normal. e.g.<br/> * %html(xmlns:me="http://www.example.com/me" html_attrs('en-gb', false))<br/> * produces<br/> * <html xml:lang="en-gb" xmlns="http://www.w3.org/1999/xhtml" xmlns:me="http://www.example.com/me"> * * PHamlP also allows for the language to be defined using PHP code that can * be eval'd; the code must end with a semi-colon (;). e.g.<br/> * %html(html_attrs("FW::app()->language);", false))<br/> * produces (assuming FW::app()->language returns 'en-gb')<br/> * <html xml:lang="en-gb" xmlns="http://www.w3.org/1999/xhtml"> * *

Parameters

string document language. Default = en-us: * @param boolean whether the html element has the lang attribute. Default: true * Should be set false for XHTML 1.1 or greater documents * @return string the block with string appended.

1 call to HamlHelpers::html_attrs()
HamlParser::htmlAttrs in phamlp/haml/HamlParser.php
* Returns an array of attributes for the html element. *

File

phamlp/haml/HamlHelpers.php, line 90

Class

HamlHelpers
HamlHelpers class. Contains methods to make it easier to do various tasks.

Code

public static function html_attrs($language = 'en-us', $lang = true) {
  return $lang ? array(
    'xmlns' => self::XMLNS,
    'xml:lang' => $language,
    'lang' => $language,
  ) : array(
    'xmlns' => self::XMLNS,
    'xml:lang' => $language,
  );
}