Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 320 Vote(s) - 3.57 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print raw html strings on EJS

#1
I'm using express.js with EJS templates and i'm trying to do something like this:

<%= "<a href='#'>Test</a>" %>

but it prints this:

<a href='#'>Test</a>

how can i print "html safe" strings?
Reply

#2
You should use html code everywhere, and use the EJS tags only where you need dynamic data. Example:

<a href='<%= user.id %>'><%= user.name %</a>

To specifically answer your question you can use `<%- "<tags_here>" %>` to output **unescaped** HTML data.
Reply

#3
for raw output html in ejs you can use this code

<%- "<a href='#'>Test</a>" %>
Reply

#4
This are the available options according to the docs

1. <% 'Scriptlet' tag, for control-flow, no output
2. <%_ ‘Whitespace Slurping’ Scriptlet tag, strips all whitespace before it
3. <%= Outputs the value into the template (HTML escaped)
4. <%- Outputs the unescaped value into the template
5. <%# Comment tag, no execution, no output
6. <%% Outputs a literal '<%'
7. %> Plain ending tag
8. -%> Trim-mode ('newline slurp') tag, trims following newline
9. _%> ‘Whitespace Slurping’ ending tag, removes all whitespace after it

Looks like the option you need is the number 4





Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through