Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jul 13, 2018 @ 10:30
    Bo Damgaard Mortensen
    0

    Remove HTML from Nested Content header

    Hi all,

    Does anyone know if it's possible to strip HTML from the Nested Content header?

    My header is set to render the first 100 characters of a RTE (since that's the only property on the document type), but it outputs the paragraph tags:

    enter image description here

    Thanks in advance :-)

  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Jul 13, 2018 @ 15:36
    Søren Kottal
    1

    Try setting the label to something

    {{ bodyText.replace(/(<([^>]+)>)/ig, "").substring(0,100) }}

    assuming your property alias is bodyText.

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jul 14, 2018 @ 08:51
    Bo Damgaard Mortensen
    0

    Thanks a lot for your reply, Søren!

    That was my thoughts exactly, but it gives me this in the console:

    enter image description here

    Not sure if it's possible to perform JS magic inside the angularjs brackets (?) Also tried with just {{ bodyText.innerText }} and {{ bodyText.text() }}, but no result :-)

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jul 14, 2018 @ 17:07
  • BY-DGR 1 post 95 karma points
    Jul 19, 2019 @ 09:34
    BY-DGR
    104

    If the question is still relevant, here is the solution we're using in our projects:

    {{!!BodyText ? (BodyText | ncRichText | limitTo:100).trim() + '…' : '<Empty Content>'}}
    

    It appeared that this Angular filter is listed in "Nested Content" manual: https://our.umbraco.com/documentation/getting-started/backoffice/Property-Editors/Built-in-Property-Editors/Nested-Content/

  • Andrei 15 posts 99 karma points
    May 07, 2020 @ 13:43
    Andrei
    4

    Found out there is a 'truncate' filter also available (8.6+), so I'm using it like this:

    <ComponentName>{{!!heading ? ': ' + (heading | ncRichText | truncate:true:150) : ''}}
    

    'true' param says keep whole words - I think

    150 - max length

    dots (...) are added if the text is longer

    This is a little better then previous answer, because here, the ending dots are only added when the text is too long.

  • Murray Roke 503 posts 966 karma points c-trib
    Jan 12, 2022 @ 02:09
    Murray Roke
    0

    Just this seems to work nicely:

    {{text | ncRichText | truncate:true:100}}
    
Please Sign in or register to post replies

Write your reply to:

Draft