Skip to content

Latest commit

 

History

History
executable file
·
49 lines (32 loc) · 1.87 KB

README.markdown

File metadata and controls

executable file
·
49 lines (32 loc) · 1.87 KB

Json Formatter

This extension saves input fields and markdown textareas to a Json encoded string (escaping invalid characters: single quote, quotes, backslash, and control characters like \n or \t), to make easier the output of a Json page.

Three text formatters are available:

  • Json String for input fields (string formatter)
  • Json Title for input fields (string formatted with title case)
  • Json CommonMark for textareas (markup formatter)

Dependencies to use all formatters and output a Json page

Installation & Updating

This extension uses Composer for autoloading and dependency management.

Make sure to include required dependencies and autoload instructions from its composer.json in your project's main composer.json and run composer update before installing this extension.

Information about installing and updating extensions can be found in the Symphony documentation at http://getsymphony.com/learn/.

Output a Json Page from Symphony CMS

Make sure to install the Content Type Mapping extension to create a new page with a json type, and set your xsl template as a pure text output:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output
    method="xml"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="yes" />

<xsl:template match="data">{
    "yourdata" : <xsl:value-of select="xpath/to/your/Json/formatted/field/value"/>
}</xsl:template>