HTML Attribute Content takes a string and preps it for use inside HTML tag attributes. You might find this handy when using content inside attributes of certain tags, like <meta>
tags used by Twitter Cards.
NOTE: This add-on is largely not needed in ExpressionEngine 4. Most variables can use the :attr_safe
modifier. This plugin can still be useful on arbitrary text in a template, from non-standard sources.
- ExpressionEngine 4
Note: If your tagdata contains an ExpressionEngine typography code-syntax highlighted codeblock, it will be stripped in its entirety, since it cannot be summarized.
It strips tags, turns single and double quotes into entities, then optionally limits to a fixed number of characters (retaining whole words), and appends a terminating character.
{exp:html_attribute_content limit='200' end_char='…'}
content to make safe for use in a tag parameter
{/exp:html_attribute_content}
limit='200'
The number of characters to limit the output to (keeps whole words).
double_encode='yes'
yes/no. Whether or not to double-encode character entities.
end_char='…'
A terminating character (or characters) to append to the string. The limit parameter takes this into consideration, so your final string will still be within the bounds of your specified limit.
unicode_punctuation='yes'
Whether or not to use unicode punctuation characters instead of entities. Handy for things like meta tags, where HTML entities may not be parsed.
- Modified for ExpressionEngine 4
- Switched to ExpressionEngine's
attributeSafe()
formatter for application consistency.- NOTE: this may flip your
double_encode=
parameter setting, as the new default is to not double encode. - This also adds the
unicode_punctuation=
parameter
- NOTE: this may flip your
- standardizing MIT license
- Updating build system for GitHub download generation.
- Cleaned up GitHub release download package
- Fixed a typo in the README
- added
double_encode=
parameter to optionally disable double-encoding of character entities
- Updated plugin to be 3.0 compatible
- Released
Copyright (c) 2015 EllisLab, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of EllisLab, Inc. shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from EllisLab, Inc.