I have a requirement to generate HTML from python. For that I am using HTML module.
As I use angularJS in my application I have to add attribute like 'ng-controller' in div tag.(A attribute name that contain hyphen)
for example
<div ng-controller='myController'></div>
HTML module does not allow hyphen or any special character as a part of attribute name.
I tried a lot, But I am not able to find any solution. Can anyone please help me on this?
I recently checked HTML module there is raw_text() function which allow user to explicitly add HTML code.
from html import HTML()
h = HTML()
h.raw_text('<div ng-controller="a"></div>')
Related
Hey there folks :) I am trying to set up a search engine with elasticsearch/node.js, express and vue.js. I would like the search results to be clickable links, but they are only returning non-clickable html. I have tried adding normal html A- tags to the .json file, but on the front end this renders as a non clickable html text and not as a clickable link. Any suggestions would be really appreciated
this is what I have tried, just as a test:
Visit our HTML tutorial
I have had a look on google for possible solutions but all I could find were references to the normal html a-tag and that both j.son and vue.js can take those?
If I correctly get the issue, At FE your link get rendered as sting which is Google . You need to use v-html in this case to tell element to render the passed value as html not as string
//Suppose you have this vue data prop
let url = Google
Now In you html part Just use v-html to render
<div class="foo">
<template v-html="url" />
</div>
when i display ckeditor text the html tags are also displayed. how can a i show only the text? i'm getting this:
<b>Paragraph</b>
Paragraph
I use Jade template and node.
It's possible to delete Tag before save in database ? or remove tag after ?
Thanks.
I found a solution.
Juste use !{value} instead of #{value} with Jade template to decode html entities.
value contains html entities.
use unescape syntax in the pug file.
p
!= 'This code is <strong>not</strong> escaped!'
or
- var riskyBusiness = "<em>This code is <strong>not</strong> escaped!</em>";
.quote
p Joel: !{riskyBusiness}
I cannot identify the object of the icon showed in the attached screen shot. I have shown the HTML code as well.
The ID's are getting changed dynamically.
Can anyone guide on how to identity this kind of objects in Selenium?
If the ID is always changed, I recommend using CssSelector instead.
For instance,
<div id="running_number_12345" class="icon something">...</div>
You can use locator
driver.FindElement(By.CssSelector("div[class*='icon something']"));
If your icon doesn't have any specific css pattern, I recommend adding something in class attribute. If not, you have to use complex CssSelector to find it.
Try this
driver.findElement(By.cssSelector(".icon something"));
I have gotten the hang of using the html agility pack to find specific nodes using their attributes and xpaths. The problem is, I've been doing this manually for each of my projects (opening the website html and scanning for the nodes that have the text i need). Is there a way to select a single node by its inner text? This would make it easier to write an update script for websites whose content scheme is the same, but attribute tags change values over time. Thanks in advance!
Would be better if you have provided sample HTML, but since you haven't, let's assume we have HTML containing this markup :
<body>
<div class="foo">bar</div>
</body>
You can select the <div> by it's attribute using HtmlAgilityPack's SelectSingleNode() and XPath like so :
myHtmlDocument.DocumentNode.SelectSingleNode("//div[#class='foo']");
or you can select the same by the inner text like so :
myHtmlDocument.DocumentNode.SelectSingleNode("//div[.='bar']");
Hope this help.
I would like to change the code before or after jade render HTML. I need to change the code to add some specific functions. For example
h4#headline Click to register
a(href="myLink", data-type="foo") Here
I would like to prepare all links or html tags with data-type by the value in the tag.
Is that possible or has anybody experience with that?
Thanks for help!