Nikita Yunoshev
Nikita Yunoshev

Reputation: 409

Show HTML text without executing it

I have a tooltip:

         <i
            class="fa fa-info-circle infopoint"
            role="button"
            data-toggle="popover"
            data-placement="top"
            data-trigger="hover"
            data-content="<a href='qwe'>URL text</a>."
        ></i>

And I need to show exactly like this, without transforming it in a link. I'm writing it in Blade template. And I've tried {!! !!} and {{ }} and html_entity_decode.

Upvotes: 1

Views: 147

Answers (1)

No Name
No Name

Reputation: 612

htmlspecialchars should do the trick

htmlspecialchars('<i
        class="fa fa-info-circle infopoint"
        role="button"
        data-toggle="popover"
        data-placement="top"
        data-trigger="hover"
        data-content="<a href="qwe">URL text</a>."
    ></i>');

If you only want data-content to show as text

data-content=" {{ htmlspecialchars("<a href='qwe'>Your html code</a>") }}"

Upvotes: 4

Related Questions