createCssHook - Mura Docs v7.0

createCssHook

A Mura Scope helper method to dynamically create CSS-friendly hooks for use within your layout templates. Pass in any string of text, and Mura will strip out CSS-unfriendly characters (e.g., script tags, HTML tags, etc.), and create a CSS-friendly string. Spaces, underscores, and bad characters (such as entity-encoded characters, etc.) are replaced with hyphens. Any capital letters are converted to lowercase. If the first character is numeric or begins with a hyphen, the character will be stripped from the resulting string.

Function Syntax

m.createCssHook( text )

Parameters

Parameter Type Req/Opt Default Description
text string Req  

A string to use to create a CSS-friendly hook with.

Usage

Use this function to create CSS-friendly hooks.

Example

The following example outputs a class of "body-" and is appended with a CSS-friendly hook based on a content item's "Title".

<cfoutput>
<body class="body-#m.createCssHook(m.content('title'))#">
  ...
</body>
</cfoutput>

In the example above, if the "Title" was "About Us", the output would result in the the following.

<body class="body-about-us">
  ...
</body>