Skip to main content

Posts

Showing posts with the label render

Don't put html, head and body tags automatically into beautifulsoup content

Was making a parser recently with BeautifulSoup. Came to the final with rendering contents of the edited text. Like so: text = "<h1>Test text tag</h1>" soup = BeautifulSoup(text, "html5" ) text = soup . renderContents() print text It renders those contents with a result wrapped into the <html>, <head> and <body> tags. So print output looks like so: '<html><head></head><body><h1>Test text tag</h1></body></html>' That's a feature of the html5lib library, it fixes HTML that is lacking, such as adding back in missing required elements. The workaround is simple enough: text = soup . body . renderContents() This solution will return an inside of the <html> tag <body>. Result is: text = '<h1>Test text tag</h1>'

Meteor: Run/Bind JavaScript after rendering a template elements

Being studying Meteor myself I'd like to help beginners like me. I have searched for certain decisions that became wired to me after python development. So I'll just leave them here for your consideration. Imagine a situation when you need to bind your plugins to a newly rendered template. If you are diving into asynchronous JS dev, like I did and have developed AJAX websites... You will, one word, be quite confused because main concepts are different from the one's you used to know. Anyhow I'd try to explain on this simple task. Assume we have a template: < template name = "site-part" > < p > {{my-text}} </ p > </ template > And I render it's content like so: Template . site - part . content = function ( ) { return Session . get ( " my_data " ) ; } So I have this template piece rendered when "my_data" variable appears in session. And I have events binded to newly rendered webpage:...

Django: How to add Google +1 button to your website.

What is Google +1 button? It's new Google social button. It's much similar to Facebook "Like" button. While available during one month it earned popularity that could compete with Facebook's social button. Corporation of Good knows what to do, so you probably want to have one on your website inline with Facebook's Like... Add Google +1 button to your site: - Open http://www.google.com/webmasters/+1/button/index.html and generate own button for your website. Google proposes HTML code like this: <html>   <head>     <title> +1 demo: Basic page </title>     <link rel = "canonical" href = "http://www.example.com" />     <script type = "text/javascript" src = "https://apis.google.com/js/plusone.js" >     </script>   </head>   <body>     <g:plusone></g:plusone>   </body> </html> It's quite simple, as you can see. And that's ...