pattern-lab / patternlab-php-core

This repository provides the core functionality for Pattern Lab. It is meant to be used from within an Edition with a PatternEngine and StarterKit.
http://patternlab.io/
MIT License
43 stars 62 forks source link

Render mustache element as string #171

Open NachoMoment opened 5 years ago

NachoMoment commented 5 years ago

Is there a way to render a mustache element as a string instead of html? My element's html wraps and is 3 lines long so something like this '{{>my-element}}' doesn't work as the ' char doesn't show up at the end of the 3rd line.

bradfrost commented 5 years ago

Hey @NachoMoment, thanks for the issue. Is there any way you could provide an example of the wrapping html that's causing an issue? I'm trying to wrap my head around the issue but I'm not sure I understand.

NachoMoment commented 5 years ago

Sure thing, here is a screen shot of the mustache element being rendered in the chrome dev tools: wrap-example

As you can see, the first ' character shows up and the first line is a string but since it wraps, the rest of the lines do not get rendered as a string. The two most straight forward solutions to this would be to either have the ability to render it as a string or the ability to disable wrapping.

Let me know if you need anything else, thanks!

bradfrost commented 5 years ago

Is this typeAheadExample in JSON? Such as:

{
    "typeAheadExample": '<div class="form-group ...">...</div>'
}

If that's the case, breaks aren't allowed in JSON and those tags would need smushed onto one line, like so: <div><label></label><span></span></div>.

But if you're trying to render the actual HTML, you would create a pattern called typeahead.mustache or similar, and be able to write your HTML with as many line breaks and indents as you'd please:

<div class="form-group mol-typeahead-dropdown">
    <label />
    <span />
</div>

Or if typeAheadExample is in JavaScript, you can use template literals to include line breaks and indents in a string.

Sorry again if I'm still not understanding the situation. If you still need help, feel free to provide a bit more context on what you're trying to accomplish and I'll do my best to assist.

NachoMoment commented 5 years ago

I think we are on the same page, I'm just new to using pattern lab :) It looks like adjusting the json if I can is what I was looking for, I'm pretty sure it's json. Either way, looks liek it's on my end. Thanks a lot for your help!