Everything You Need to Know



Truck Engine

Truck has a number of useful functions that we categorize as utilities. These work even if you include jQuery in your project. The best part of them are what we all the "haz" guys. These functions allow you to test for a selector and write a oneliner that would require a loop in jQuery.

In jQuery you might do this:

// Change background color if Div has class "attention":
$('div').each(function(idx, ctx) {
  if ($(ctx).hasClass('attention')) {
    $(ctx).css({'background-color': 'red'});

Wheres with Truck, you would do this:

$('div').hazClass('attention').css({'background-color': 'red'});

Once you start using the "haz" guys you'll wonder how you ever got along with out the.

Please see the section on Use for more information.