├── resources ├── images │ └── plugin.png ├── icon.svg └── icon-mask.svg ├── releases.json ├── LICENSE.txt ├── twigextensions └── EntityDecodeTwigExtension.php ├── README.md └── EntityDecodePlugin.php /resources/images/plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nystudio107/entitydecode/master/resources/images/plugin.png -------------------------------------------------------------------------------- /releases.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "version": "1.0.0", 4 | "downloadUrl": "https://github.com/nystudio107/entitydecode/archive/master.zip", 5 | "date": "2016-01-24T17:08:22.656Z", 6 | "notes": [ 7 | "[Added] Initial release" 8 | ] 9 | } 10 | ] -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 Andrew Welch 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. -------------------------------------------------------------------------------- /resources/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 14 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /resources/icon-mask.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 14 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /twigextensions/EntityDecodeTwigExtension.php: -------------------------------------------------------------------------------- 1 | new \Twig_Filter_Method($this, 'unescape'), 49 | ); 50 | } 51 | 52 | /** 53 | * Returns an array of Twig functions, used in Twig templates via: 54 | * 55 | * {% set this = someFunction('something') %} 56 | * 57 | * @return array 58 | */ 59 | public function getFunctions() 60 | { 61 | return array( 62 | 'unescape' => new \Twig_Function_Method($this, 'unescape'), 63 | ); 64 | } 65 | 66 | /** 67 | * Our function called via Twig; it can do anything you want 68 | * 69 | * @return string 70 | */ 71 | public function unescape($text = null) 72 | { 73 | $result = html_entity_decode($text); 74 | 75 | return $result; 76 | } 77 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/) 2 | 3 | # DEPRECATED 4 | 5 | This Craft CMS 2.x plugin is no longer supported, but it is fully functional, and you may continue to use it as you see fit. The license also allows you to fork it and make changes as needed for legacy support reasons. 6 | 7 | # EntityDecode plugin for Craft CMS 8 | 9 | Decodes HTML Entities 10 | 11 | ## Installation 12 | 13 | To install EntityDecode, follow these steps: 14 | 15 | 1. Download & unzip the file and place the `entitydecode` directory into your `craft/plugins` directory 16 | 2. -OR- do a `git clone https://github.com/nystudio107/entitydecode.git` directly into your `craft/plugins` folder. You can then update it with `git pull` 17 | 3. Install plugin in the Craft Control Panel under Settings > Plugins 18 | 4. The plugin folder should be named `entitydecode` for Craft to see it. GitHub recently started appending `-master` (the branch name) to the name of the folder for zip file downloads. 19 | 20 | EntityDecode works on Craft 2.4.x and Craft 2.5.x. 21 | 22 | ## EntityDecode Overview 23 | 24 | If you have data coming in from an external source that is already HTML Entity encoded, and you need it decoded to raw HTML, EntityDecode lets you decode it. 25 | 26 | ## Using EntityDecode 27 | 28 | Both of these methods accomplish the same thing: 29 | 30 | {# Output the html_entity_decode()'d text using the 'unescape' function #} 31 | {{ unescape( TEXT ) |raw }} 32 | 33 | {# Output the html_entity_decode()'d text using the 'unescape' filter #} 34 | {{ TEXT | unescape() |raw }} 35 | 36 | Twig by default encodes output from `{{}}` tags so we use the `|raw` to ensure that the output will be raw HTML; if that's not what you want, remove it. 37 | 38 | Under the hood, it just calls the PHP function `html_entity_decode()` and returns the resulting data. 39 | 40 | ## EntityDecode Changelog 41 | 42 | ### 1.0.0 -- 2016.01.24 43 | 44 | * Initial release 45 | 46 | Brought to you by [nystudio107](http://nystudio107.com) 47 | -------------------------------------------------------------------------------- /EntityDecodePlugin.php: -------------------------------------------------------------------------------- 1 |