mazedigital / association_output

Association Output for Symphony: Inline XML
MIT License
5 stars 4 forks source link

Association Output not outputting Markdown #3

Closed jdsimcoe closed 10 years ago

jdsimcoe commented 10 years ago

So I have Association setup and was able to get data to output successfully. However, I have several fields that are Markdown fields and the Association Output doesn't render any markup, it just gives me straight paragraphed text:

screenshot

I was able to do a workaround with a second datasource, but is there provision for this type of use-case as SSM used to output formatted and/or unformatted fields?

nilshoerrmann commented 10 years ago

Ah, good catch. We forgot to add the output modes to the field selection in the Data Source editor. Thanks for the report!

jdsimcoe commented 10 years ago

You bet! I was scratching my head trying to figure out what to do.

On Thursday, July 17, 2014 at 9:51 PM, Nils Hörrmann wrote:

Ah, good catch. We forgot to add the output modes to the field selection in the Data Source editor. Thanks for the report!

— Reply to this email directly or view it on GitHub (https://github.com/hananils/association_output/issues/3#issuecomment-49395265).

nilshoerrmann commented 10 years ago

Please checkout the latest beta that now includes the missing field modes: https://github.com/hananils/association_output/releases/tag/1.0.0beta2

jdsimcoe commented 10 years ago

Ok so the output modes are working, except they don't do HTML-encoding:

https://gist.github.com/9e5f3598b037cc2f95c1

This is a sample output where I have a Markdown Text Formatter on a Textarea that is not outputting any HTML.

nilshoerrmann commented 10 years ago

Do these fields return any values when you use them in the default Data Source output (not using this extension)? The text formatters are run when you save your entries, it's nothing Symphony does on the fly – so this shouldn't be related to this issue.

Or are you talking about the option in the Data Source editor to HTML-encode the output?

nilshoerrmann commented 10 years ago

Just looking at this again: are we talking about the text node or the quote and aside nodes?

jdsimcoe commented 10 years ago

See my updated Gist:

https://gist.github.com/jdsimcoe/9e5f3598b037cc2f95c1

As you can see the association output is working and spitting out HTML tags. However I can't figure out how to get them successfully to render HTML in my templates. Also, the standard datasource has an HTML-encoding option which could be why the difference.

This is how I normally output HTML from HTML-encoded datasource values:

<xsl:value-of select="text" disable-output-escaping="yes" />

Is there a way I can get HTML to spit out on my page from the association output in the Gist above?

nilshoerrmann commented 10 years ago

Okay, I think there are two different aspects:

HTML Encoding

There is an option to HTML encode the Data Source output. This option is not passed to the association output at the moment – but it should. We'll add this.

Output

I'm a bit confused that you are using HTML encoding for your Data Source if you'd actually want to return unencoded markup. Taking your example:

<item id="7" handle="about-text" section-handle="matrix" section-name="Matrix">
  <title handle="about-text">About: Text</title>
  <text mode="formatted">
    <p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Nulla vitae elit libero, a pharetra augue. Nullam quis risus eget urna mollis ornare vel eu leo. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum.</p>
    <p>Vestibulum id ligula porta felis euismod semper. Nullam quis risus eget urna mollis ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit. Donec ullamcorper nulla non metus auctor fringilla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras mattis consectetur purus sit amet fermentum. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
    <p>Nullam id dolor id nibh ultricies vehicula ut id elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
    <ul>
      <li>list 1</li>
      <li>list 2</li>
      <li>list 3</li>
    </ul>
  </text>
</item>

I'd usually use one of the following ways to generate my output:

<!-- simple way -->
<xsl:copy-of select="item/text/*" />

<!-- advanced way, using Allen's ninja technique, https://github.com/hananils/kit/blob/master/ninja.xsl -->
<xsl:apply-templates select="item/text/*" mode="ninja" />    

Both XSLT elements will return the same result:

<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Nulla vitae elit libero, a pharetra augue. Nullam quis risus eget urna mollis ornare vel eu leo. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum.</p>
<p>Vestibulum id ligula porta felis euismod semper. Nullam quis risus eget urna mollis ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit. Donec ullamcorper nulla non metus auctor fringilla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras mattis consectetur purus sit amet fermentum. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
<p>Nullam id dolor id nibh ultricies vehicula ut id elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
<ul>
  <li>list 1</li>
  <li>list 2</li>
  <li>list 3</li>
</ul>

So I'd say that you don't have to HTML encode your XML output at all.

jdsimcoe commented 10 years ago

I inherited my techniques from a guy who didn't know how to output in Symphony correctly. Thanks for sharing this.

What does ninja mode do?

nilshoerrmann commented 10 years ago

The ninja technique allows you to alter your markup on the fly. For instance, if your users enter their content with Markdown, they quite possibly start with an h1 or # as their first headline. But in your HTML you might need an h3. So you can match the h1 and turn it into an h3. You could also wrap all images in a div or convert all paragraphs to blockquotes or use content from your XML to generate SVG graphics.

Have a look here for an introduction: http://www.getsymphony.com/learn/articles/view/html-ninja-technique/. It's a powerful technique, but it takes a moment to see the full set of possibilities it offers.

jdsimcoe commented 10 years ago

Beautiful. Thanks for the helpful introduction! Consider this resolved. How close are you to having the Association Entry form finished? This Association work is really great to see come together.

nilshoerrmann commented 10 years ago

How close are you to having the Association Entry form finished?

We are working on it but we will not publish any release dates – that never works out well :) But it won't take long anymore.

jdsimcoe commented 10 years ago

I understand. Look forward to testing it when it is released.

nilshoerrmann commented 10 years ago

Consider this resolved

Good. But we'll add the HTML-encoding nevertheless – might still be useful.