简体   繁体   中英

Writing HTML layout/template within javascript bookmarklet

I have a bookmarklet which creates a UI for the user to interact with. Currently, I have been using $('<element>').addClass().css({..}); , but that becomes hard to maintain. Is there a better way to do this?

I have also tried doing something like

var html = "<div class='someclass'>";
html += "<more html/>";
html += "</div>"

Which is also incredibly hard to maintain. Is there a way I can write html within javascript, or a library like jade that i can use WITHIN a javascript bookmarklet?

Yes, there is a Domain Specific Language implementation in JavaScript to allow you to write more expressive HTML in JavaScript called Pithy .

Please remember that writing large amounts in Pithy is maybe not a good idea and you rather want to use a proper client side templating engine such as DustJS or many others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM