rennat / pynliner

Python CSS-to-inline-styles conversion tool for HTML using BeautifulSoup and cssutils
http://pythonhosted.org/pynliner/
181 stars 93 forks source link

Embed javascript in the HTML file #24

Closed rushiagr closed 11 years ago

rushiagr commented 11 years ago

I'm slightly new to web technologies, so it might seem weird to you that I'm suggesting this. Maybe it is too easy, or maybe my understanding about how javascript-html-css work in tandem is shaky.

I'm encountering a use case where I have to generate one single-file html page, which contains all the css and javascript. If I can put all the 'required' JS functions inside tags.

I don't think this is something pynliner should do as it is expressly a CSS utility.

Even though I don't think pynliner should do any Javascript inlining, you can inject your own modifications inside the pynliner process when using it:

instead of the shorthand method

pynliner.fromString(my_file_string)

use it directly

my_pynliner = pynliner.Pynliner() # get a Pynliner my_pynliner.from_string(my_file_string) # tell it what to process my_pynliner._get_soup() # tell it to make the beautiful soup my_pynliner.soup # get the soup and do whatever you'd like with it ... my_pynliner.run() # tell the Pynliner instance to continue with the inlining of CSS

— Reply to this email directly or view it on GitHubhttps://github.com/rennat/pynliner/issues/24#issuecomment-19703560 .

Regards, Rushi Agrawal Ph: +91 99 4518 4519