1.4 KiB
DRY and Pythonic jQuery?
Apparently, groovy:spring:java as jabs:jquery:javascript. As if jQuery wasn't short enough already.This 2009 post captures the era's fascination with domain-specific languages and syntactic sugar—an impulse that would later manifest in CoffeeScript, TypeScript, and modern JavaScript transpilation tools.
Jabs lets you write this jQuery code:
jQuery(function() {var $ = jQuery;
$("[default_value]").blur(function() {var self = $(this);if(self.val() === "") {self.val(self.attr("default_value"));}}).focus(function() {var self = $(this);if(self.val === self.attr("default_value")) {self.val("");}}).blur();});
By typing this:
$ [default_value]:blurif @value === ""@value = @default_value:focusif @value === @default_value@value = "".blur
HAML tactics FTW.HAML's influence on web development was significant—its indentation-based syntax and DRY principles influenced template engines across many languages, from Slim in Ruby to Pug in JavaScript.