| 
 | 1 | +[](http://www.apache.org/licenses/LICENSE-2.0)  | 
 | 2 | +[]([https://david-dm.org/JelteMX/mendix-text-template](https://david-dm.org/JelteMX/mendix-text-template))  | 
 | 3 | +[]([https://david-dm.org/JelteMX/mendix-text-template?type=dev](https://david-dm.org/JelteMX/mendix-text-template?type=dev))  | 
 | 4 | +[-orange.svg)](https://docs.mendix.com/developerportal/app-store/app-store-content-support)  | 
 | 5 | +[](https://appstore.home.mendix.com/link/modeler/)  | 
 | 6 | +  | 
 | 7 | +  | 
 | 8 | +[](https://github.com/JelteMX/widget-test-projects)  | 
 | 9 | + | 
 | 10 | +# Mendix Text Template  | 
 | 11 | + | 
 | 12 | +Render Markdown/HTML from a Text template. As powerful as the HTMLSnippet/Formatstring widget, but with more flexibility.  | 
 | 13 | + | 
 | 14 | +This uses the [react-markdown](https://github.com/rexxars/react-markdown) library (MIT License) and [react-shortcodes](https://github.com/djm/remark-shortcodes) library (MIT License)  | 
 | 15 | + | 
 | 16 | +  | 
 | 17 | + | 
 | 18 | +> See test-project (**_to be published_**) for a live demo!  | 
 | 19 | +
  | 
 | 20 | +  | 
 | 21 | + | 
 | 22 | +Tested in the following Browsers:  | 
 | 23 | + | 
 | 24 | +- IE11 / Edge  | 
 | 25 | +- Chrome, Firefox, Safari  | 
 | 26 | +- Should work on Mobile Web  | 
 | 27 | + | 
 | 28 | +> This widget is built in Mendix 8.6.4. It would probably work in 8.0.0, but there are no guarantees.  | 
 | 29 | +
  | 
 | 30 | +## Features  | 
 | 31 | + | 
 | 32 | +- Render Markdown (string) as HTML. Markdown is [Github Flavored Markdown](https://guides.github.com/features/mastering-markdown/)  | 
 | 33 | +- Render HTML from a text template. It will try to parse it as proper React elements.  | 
 | 34 | +- Use your standard text template in Mendix, where values from your Mendix objects are replaced by `{1}` etc  | 
 | 35 | +- Want to use static/dynamic images? You can get the direct url in your template using the `$$[placeholder]$$` strings  | 
 | 36 | +- Using a file? You can get a direct url to it with the `$$file$$` string  | 
 | 37 | + | 
 | 38 | +## TODO  | 
 | 39 | + | 
 | 40 | +- Currently the `[[ shortcode ]]` template (everything between `[[` and `]]`) is reserved for future shortcode support. You can think of something like `[[ youtube id="" ]]` for a YouTube embed. This is not there yet. Any shortcode that you will put in there will not be rendered.  | 
 | 41 | +- There might be useful other strings (`$$key$$`) added later. Currently I am only using this for images and a file  | 
 | 42 | +- File is only a single one, because of a bug in Mendix Studio 8.6.4 (cannot create a list of files like images)  | 
 | 43 | +- It always renders a container with the class name. This could be made optional (although not ideal)  | 
 | 44 | +- Mendix Studio support will be added later  | 
 | 45 | + | 
 | 46 | +## What is it __NOT__?  | 
 | 47 | + | 
 | 48 | +Although this is very powerful, this widget does __NOT__ support inline scripts like you can do with the HTMLSnippet/Javascript snippet. The reason for that is simple: It should not be done in the Mendix page itself. I might add a ``[[ script ]]`` shortcode later where you can load a script from an external source.  | 
 | 49 | + | 
 | 50 | +By default HTML is escaped and should not render. You can switch this off. If you happen to find an XSS vulnerability (e.g. you can somehow get `alert(1)` working), please contact me and I will see how we can prevent this!  | 
 | 51 | + | 
 | 52 | +## Usage  | 
 | 53 | + | 
 | 54 | +- Place the Text Template widget on your page (doesn't need a context like dataview)  | 
 | 55 | +- Define your template. If you have a context, you can define Parameters. These parameters can then be used in your template with brackets (`{1}` etc). __Note: Because Mendix uses the brackets, you cannot use them for other purposes in your template!__  | 
 | 56 | +- Want to use HTML? `HTML -> Escape HTML: No`. Use with caution. Also, for some elements (like in the Test-project with an SVG) you might want to surround them with a `<div>` element  | 
 | 57 | +- Misc settings may or may not be usefull. They will add certain `data-` tags to all generated elements. Also, if there are certain elements prohibited, you can disable them (This is a list like `image,strong`). When disabling certain elements, you can choose whether or not to show them (if you want to, set **Unwrap disallowed** to Yes)  | 
 | 58 | +- This element has Conditional Visibility built-in  | 
 | 59 | + | 
 | 60 | +## Test project  | 
 | 61 | + | 
 | 62 | +The Test-project can be downloaded here: __*To be published*__  | 
 | 63 | + | 
 | 64 | +## Issues, suggestions and feature requests  | 
 | 65 | + | 
 | 66 | +Please report your issues [here](https://github.com/JelteMX/mendix-text-template/issues)  | 
 | 67 | + | 
 | 68 | +## License  | 
 | 69 | + | 
 | 70 | +Apache 2  | 
0 commit comments