4 ms·
Reminds me of Genshi, which was really cool about.... 15 years ago. https://pythonhosted.org/Genshi/templates.html https://pythonhosted.org/Genshi/templates.htm
by geofft 5y ago
Reminds me of Genshi, which was really cool about.... 15 years ago. https://pythonhosted.org/Genshi/templates.html https://pythonhosted.org/Genshi/templates.html
The big difference between Genshi and Jinja (which ended up winning) is that Genshi templates are valid XHTML using the "py:" XML namespace for control flow, and Jinja templates use their own syntax (and therefore can template things other than XML).
- DonHopkins 5y agoI love Genshi, and still occasionally maintain a big Python project that uses it for several purposes (generating html, and processing xml from and to various formats)! Genshi was based on an earlier Python XML templating system called Kid, which is what TurboGears used by default, before switching to Genshi. You write Genshi templates as XML (although it also supports plain text templates), and it had serializers that translated the xml streams your templates produce to xhtml or different varieties of html. Genshi is also great for generating other formats of xml, much easier to use and more powerful than XSLT. For example, I used it to generate tediously repetitive and low level VML and CCML files for an interactive voice response system, by writing high level Genshi macros and xml data, which felt a lot like Lisp programming! Genshi is so simple (which makes it easy to learn and use), it would be trivial to implement a Genshi-compatible xml processor in JavaScript, using JavaScript expressions to evaluate strings for if conditionals, variable bindings, etc. It may be 15 years old, but I'd joyfully use Genshi again to transform XML to XML, long before I ever considered coming within a mile of XSLT (yech). My impression of XSLT is that there were representatives from every different programming language paradigm on the XSLT standard committee, and each one of them was able to get just enough of what was special about their own paradigm into the standard to showcase it while sabotaging the others and making them all look foolish, but not enough to actually get any work done or lord forbid synergistically dovetail together into a unified whole. The only way I was ever able to get anything done with XLST was to use Microsoft's script extensions to drop down into JavaScript and just solve the problem with a few lines of code. And that begs the question of why am I not just solving this problem with a few lines of JavaScript code instead of inviting XSLT to the party? But for generating HTML with JavaScript/TypeScript now, I prefer Svelte. But partially because it has a lot of similarities with Genshi and OpenLaszlo. OpenLaszlo is another XML/JavaScript based programming language I really enjoyed using, but that's now obsolete. It was a lot like Adobe FLEX, but it existed before FLEX, and it was designed to abstract the Flash player away instead of locking you into the Flash player like FLEX was. You wrote xml files with embedded JavaScript (ActionScript for FLEX) scripts and expressions. And the Laszlo compiler could compile it into either a .flv file that ran in the Flash player, or JavaScript/HTML that ran identically in the web browser. I've written about OpenLaszlo before. (Excerpting old posts and updating broken links to archive.org): https://news.ycombinator.com/item?id=7756215 https://news.ycombinator.com/item?id=7756215 DonHopkins on May 16, 2014 | parent | context | favorite | on: What web developers thought of in the noughties as... Some alternatives to MVC for user interface programming that I've used and love are constraints / data binding / events and delegates. I worked on the internals of "Garnet", a constraint based user interface management system written in Common Lisp on X11 (Brad Meyers' research system developed in the 90's at CMU) -- http://www.cs.cmu.edu/afs/cs/project/garnet/www/papers.html http://www.cs.cmu.edu/afs/cs/project/garnet/www/papers.html -- and also on the internals and applications of "OpenLaszlo", an open source cross platform XML/JavaScript based web programming system that supports Flash and browser JavaScript/HTML. https://web.archive.org/web/20070810113039/http://www.donhopkins.com/drupal/node/124 https://web.archive.org/web/20070810113039/http://www.donhop... Here is an article I wrote about constraints in OpenLaszlo and Garnet: Constraints and Prototypes in Garnet and Laszlo https://web.archive.org/web/20070823205654/http://www.donhopkins.com/drupal/node/69 https://web.archive.org/web/20070823205654/http://www.donhop... Oliver Steele (one of the architects of OpenLaszlo, and a great Lisp programmer) describes how OpenLaszlo supports "instance first development" and "rethinking MVC": http://osteele.com/archives/2004/03/classes-and-prototypes http://osteele.com/archives/2004/03/classes-and-prototypes http://osteele.com/archives/2003/08/rethinking-mvc http://osteele.com/archives/2003/08/rethinking-mvc I've used OpenLaszlo a lot, and I will testify that the "instance first" technique that Oliver describes is great fun, works very well, and it's perfect for the kind of exploratory / productizing programming I like to do. (Like tacking against the wind, first exploring by creating instances, then refactoring into reusable building block classes, then exploring further with those...) OpenLaszlo's declarative syntax, prototype based object system, xml data binding and constraints support that directly and make it easy. OpenLaszlo's declarative syntax and compiler directly support instance first development (with a prototype based object system) and constraints (built on top of events and delegates -- the compiler parses the constraint expressions and automatically wires up dependences), in a way that is hard to express elegantly in less dynamic, reflective languages. (Of course it was straightforward for Garnet to do with Common Lisp macros!) https://news.ycombinator.com/item?id=21840890 https://news.ycombinator.com/item?id=21840890 skybrian on Dec 20, 2019 | parent | context | favorite | on: Homoiconicity isn’t the point (2012) This seems similar to Ant's relationship to XML? DonHopkins on Dec 20, 2019 [–] That Ant is a domain specific language for translating XML into Java stack traces? skybrian on Dec 20, 2019 | parent [–] I meant that Ant is built on a generic language for representing data. But XML isn't a great choice and JSON wouldn't work well either. S-expressions are popular with Lisp programmers and unpopular with most other people. It seems like there might be some other solution? DonHopkins on Dec 20, 2019 | root | parent [–] My remark was just an old Java joke I repurposed for Ant! "Java is a DSL for taking large XML files and converting them to stack traces." -Andrew Back https://www.reddit.com/r/programming/comments/eaqgk/java_is_ https://www.reddit.com/r/programming/comments/eaqgk/java_is_... But in all seriousness: OpenLaszlo used XML with embedded JavaScript in a way that let you extend XML by defining your own tags in XML+JavaScript. I've done a lot of work with it, and once you make your peace with XML (which seemed like a prudent thing to do at the time), it's a really productive enjoyable way to program! But that's more thanks to the design of OpenLaszlo itself, rather than XML. https://en.wikipedia.org/wiki/OpenLaszlo https://en.wikipedia.org/wiki/OpenLaszlo OpenLaszlo (which was released in 2001) inspired Adobe Flex (which was released in 2004), but Flex missed the point of several of the most important aspects of OpenLaszlo (first and foremost being cross platform and not locking you into Flash, which was the entire point of Flex, but also the declarative constraints and "Instance First Development" and the "Instance Substitution Principal", as defined by Oliver Steele). https://en.wikipedia.org/wiki/Apache_Flex https://en.wikipedia.org/wiki/Apache_Flex https://blog.osteele.com/2004/03/classes-and-prototypes/ https://blog.osteele.com/2004/03/classes-and-prototypes/ The mantle of constraint based programming (but not Instance First Development) has been recently taken up by "Reactive Programming" craze (which is great, but would be better with a more homoiconic language that supported Instance First Development and the Instance Substitution Principle, which are different but complementary features with a lot of synergy). The term "Reactive Programming" describes a popular old idea: what spreadsheets had been doing for decades. OpenLaszlo and Garnet (a research user interface system written by Brad Myers at CMU in Common Lisp) were exploring applying automatic constraints to user interface programming. Garnet started in the early 1990's. Before that, Ivan Sutherland's Sketchpad explored constraints in 1963, and inspired the Visual Geometry Project in the mid 1980's and The Geometer's Sketchpad in 1995. https://en.wikipedia.org/wiki/Reactive_programming https://en.wikipedia.org/wiki/Reactive_programming http://www.cs.cmu.edu/afs/cs/project/garnet/www/garnet-home.html http://www.cs.cmu.edu/afs/cs/project/garnet/www/garnet-home.... https://en.wikipedia.org/wiki/Sketchpad https://en.wikipedia.org/wiki/Sketchpad http://math.coe.uga.edu/TME/Issues/v10n2/4scher.pdf http://math.coe.uga.edu/TME/Issues/v10n2/4scher.pdf https://en.wikipedia.org/wiki/The_Geometer%27s_Sketchpad https://en.wikipedia.org/wiki/The_Geometer%27s_Sketchpad I've written more about OpenLaszlo and Garnet: What is OpenLaszlo, and what's it good for? https://web.archive.org/web/20160312145555/http://donhopkins.com/drupal/node/124 https://web.archive.org/web/20160312145555/http://donhopkins... >Declarative Programming: Declarative programming is an elegant way of writing code that describes what to do, instead of how to do it. OpenLaszlo supports declarative programming in many ways: using XML to declare JavaScript classes, create object instances, configure them with automatic constraints, and bind them to XML datasets. Declarative programming dovetails and synergizes with other important OpenLaszlo techniques including objects, prototypes, events, constraints, data binding and instance first development. Constraints and Prototypes in Garnet and Laszlo https://web.archive.org/web/20160405015129/http://www.donhopkins.com/drupal/node/69 https://web.archive.org/web/20160405015129/http://www.donhop... >Garnet is an advanced user interface development environment written in Common Lisp, developed by Brad Meyers (the author of the article). I worked for Brad on the Garnet project at the CMU CS department back in 1992-3. More Laszlo stuff: https://news.ycombinator.com/item?id=17360883 https://news.ycombinator.com/item?id=17360883