How to show rendered template as raw source code block? - html

I want to provide a rendered HTML block that shows an email signature - what it looks like with user data from the context - and also displays the populated HTML code as raw src to be copied for pasting into customers email signature. What would be the best (dry) way to do this?
I have tried render_to_string as a variable in the context but the HTML is rendered.

I solved this by following this answer:
How do I perform HTML decoding/encoding using Python/Django?
The rendered django template HTML needs to be decoded before it can be shown in the pre tag otherwise it will be marked up by the browser.

Related

Send html code from UI to node and adding it to a pug template

Hello so as the title says, I need to be able to fill a textbox with html code and send it to to my node backend and then out it into my pug template to show the html code writes in te textbox ( now I'm using react-quill but this always wraps the thing that I write between tags ) all the sending process is ok but I've been unable to found a way of doing this, dunno if a text area couldwork,with reacquill just work with the normal tools on the editor, but not like sending a current code with all syntax of html, like with doctype tag or the html tag

CKEditor SetData() is showing Raw HTML

I am currently using ckeditor in my Django project.
setData() in inserting the text as raw html content. Any suggestion how to convert that raw HTML to rich text when setData() us used.
Follwing command is used by me.
CKEDITOR.instances.editor1.setData( "<%- data.description %>" );
Met similar problem in Flask project. In my case, raw HTML tags were transfer to HTML entities, for example, "< p >" is transfer to "&ltp&gt", thus the setData did not consider them as HTML tags.
I think you should check the source code of your web page, and to see what is in the setData().
For Flask, the following answer solved my problem:
Passing HTML to template using Flask/Jinja2

How to save html content in mongodb via SpringBoot form

I am working on a SpringBoot based MVC application which uses mongoDB to store the data. I am using thymeleaf as the template engine. In one of the scenarios, the user needs to fill a form which is then displayed on some view.
The problem I am facing is that the user can use html tags to format the data while writing in the textArea of the form (code snippets, tabular format etc). But when I am displaying that text, the html is not being parsed and is displayed as is.
For Ex: <b>String</b> should be displayed as String but is being displayed as <b>String</b> only. When I check the source code of the page, the html tags are displayed as encoded i.e. < is showing as &lt ; etc and hence the parsing is not happening.
Can someone please help
You can output unescaped text with th:utext. From the official turorial
If we want Thymeleaf to respect our XHTML tags and not escape them, we will have to use a different attribute: th:utext (for “unescaped text”):
<p th:utext="#{home.welcome}">Welcome to our grocery store!</p>
The tutorial assumes that home.welcome is a string with html-tags:
home.welcome=Welcome to our <b>fantastic</b> grocery store!.
It goes without saying that this needs very careful validation so that only safe (whatever safe is for the particular use case) HTML is stored into the database (and no possibly malicious code like <script/> tags).

How to read the HTML page source using QTP

How to read the HTML page source using QTP
Tried with the following code, which doesn't display the complete source,
browser("micClass:=Browser").page("micClass:=Page").Object.documentElement.innerHtml
When I tried it I got the correct HTML (not including the html tag, you can get that by using outerHTML instead of innerHTML).
It could be that your seeing a different result than you're expecting because you're expecting to see the original HTML served by the server (aka static html which can be seen by right-click => View Source) and what UFT shows you is the HTML rendered in the browser (aka dynamic HTML). You can read about the differences between static and dynamic HTML here.

HTML img code src, saving and sending an E-mail or HTML form

So let's say that there is a HTML (or XHTML) code and
<img alt="...." src=".......aspx" />:
So, aspx generates image file, and there will be some image shown.
Now I want to send the generated image file to E-mail or using HTML form code, and I want my html code to do this automatically.
So, in the html code, after img code, I'd like to add codes that send the generated image automatically.
(I want a single code with img code and E-mail or HTML form code.)
What should I do?
To be honest, based on your question, it's not entirely clear what you're trying to accomplish. But, from what I gather, you could try several different approaches:
Check out this StackOverflow post: Sending an email with an image embedded in the body from C#
You can use the code from this source as a starting point: http://www.codedigest.com/Articles/ASPNET/95_Sending_Email_using_C__and_ASPNet_20.aspx (see "Sending Email with Embedded Image in the Message Body" section)
What you need to do is move the image generation logic to some library or the App_Code folder, and then call that logic twice: once from the .aspx handler that sends it for the tag, and once for the code that you also need to write that will send it in the email. Once you have the byte[] array with the image, follow lkaradashkov's link to send it in the email:
Sending an email with an image embedded in the body from C#