How to include basic "indent characters" in Sugar description and see the text correctly indented on record view (without having to edit it) ?

Hello,

I have a small issue and there is probably a trick but I don't get it.

I want to fill a basic description field (textarea) with some text, including indentation character (\t or mulitples spaces) to display the text in a proper way.

Unfortunatelly, the formating characters are removed from the view (but are still there because the text is correctly indented when I edit it).

any Idea?

Parents
  • Hey everyone,

    there's a simpler solution - just add style="white-space: pre;" to the <div> styles. The default detail.hbs has a single <div> that contains some HBS logic - keep in mind that, if you just add this style to the <div> that's there, the first line will be indented because the whitespace in the .hbs file is also included (see e.g. here). The solution is to ensure that the actual text is not surrounded by whitespaces, by wrapping all the places a value actually gets inserted in a new div. Here's an example that should work:

    <div>
    {{#if value.short}}
    {{#if collapsed}}
    <div style="white-space: pre;">{{nl2br value.short}}&hellip;</div>
    {{else}}
    <div style="white-space: pre;">{{nl2br value.long}}</div>
    {{/if}}
    <button data-action="toggle" class="btn btn-link btn-invisible toggle-text">
    {{#if collapsed}}
    {{str 'LBL_TEXTAREA_MORE' module}}
    {{else}}
    {{str 'LBL_TEXTAREA_LESS' module}}
    {{/if}}
    </button>
    {{else}}
    <div style="white-space: pre;">{{nl2br value.long}}</div>
    {{/if}}
    </div>

  • I definitely like Gabriels solution the best! Oddly enough, using his solution I think you might also be able to drop the use of nl2br in the hbs file: 

    <div>
    {{#if value.short}}
    {{#if collapsed}}
    <div style="white-space: pre;">{{value.short}}&hellip;</div>
    {{else}}
    <div style="white-space: pre;">{{value.long}}</div>
    {{/if}}
    <button data-action="toggle" class="btn btn-link btn-invisible toggle-text">
    {{#if collapsed}}
    {{str 'LBL_TEXTAREA_MORE' module}}
    {{else}}
    {{str 'LBL_TEXTAREA_LESS' module}}
    {{/if}}
    </button>
    {{else}}
    <div style="white-space: pre;">{{value.long}}</div>
    {{/if}}
    </div>




Reply Children
No Data