Javascript News

Syndicate content
Pipes Output
Updated: 48 weeks 6 days ago

Watch: Compiling Sass using grunt-contrib-watch

Fr, 2015-09-25 17:30

Learn how to use grunt’s sass, watch, and connect plug-ins to create a build system that opens a browser, and updates any change in html, or Sass code live in the browser.

Loading the player...

Continue reading %Watch: Compiling Sass using grunt-contrib-watch%

Quickly Detect Hacked Files via CRON/PHP: SuperScan

Fr, 2015-09-25 17:00

As a Certified Ethical Hacker, I'm fully aware that prevention is the best tactic to prevent hackers but, should one break through, the sooner you know it, the quicker you can act to limit the damage.

A while back, I presented a script called hashscan, designed to track site changes. Executed via a daily CRON, the script reads the files for a specified directory (e.g., an account’s public_html directory on a server), generates hashes (for files with specific file extensions), and compares them with the previous scan’s hashes stored in a database. It's a great way for site owners to be alerted to files that have been added, altered or deleted by a hacker.

In this article, I'll present an updated version of the script, called SuperScan.

Benefits of SuperScan

The primary benefit is that SuperScan will report any changes to files in an account whether the file change is an addition, alteration or deletion. SuperScan was designed not to overwhelm the webmaster. It only provides a report of changes since the last scan (the default is one hour, but can be configured via CRON) and a summary report (daily by default, although, again, it can be configured via CRON).

Because the scan of a 1500 file account takes ~0.75 seconds, SuperScan can be run frequently without affecting server performance.

To support forensic investigation, the file last modified date and time are held in the database, along with the hash value of the most recent scan (and prior scan for altered files).

The scanner file need not be changed, as all variables are set within a required configure script. It's in the configure script where you can select specific (or ALL) file extensions to be scanned or, if ALL, the file extensions to omit. Additionally, you may specify directories which the scanner will not scan.

While the SuperScan files can be tested within a webspace, I recommend that it be moved outside the webspace for production use via CRON to protect against casual hackers.

Finally, a curious additional benefit is that changes in (extensionless) error_log files are captured and can direct the webmaster’s attention to coding problems that have slipped through the testing procedures.

Continue reading %Quickly Detect Hacked Files via CRON/PHP: SuperScan%

How to Quickly Build a Chat App with Ratchet

Fr, 2015-09-25 16:00

In this tutorial, we’ll be taking a look at Ratchet, a PHP library for working with WebSockets. Let’s start by defining what WebSockets are. MDN says:

WebSockets is an advanced technology that makes it possible to open an interactive communication session between the user’s browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.

WebSockets allow us to write applications that can pass data from the browser to the server and vice-versa in real-time.

Setup

First, let’s install Ratchet using Composer:

composer require cboden/ratchet Building the App

Now we’re ready to build the app. Create a Chat.php file under the class/ChatApp directory. This would be a class under the ChatApp namespace, and it would use use Ratchet’s MessageComponentInterface and ConnectionInterface. The MessageComponentInterface is used as the basic building block for Ratchet applications, while the ConnectionInterface represents the connection to the application.

Continue reading %How to Quickly Build a Chat App with Ratchet%

October’s Editorial Theme: The Struggle

Fr, 2015-09-25 15:45

Sometimes it takes an overwhelming breakdown to have an undeniable breakthrough.

Steve Jobs got fired from the company he started.

Disney barely survived due to its founder’s poor budgeting habits.

J.K. Rowling, one of the richest women in the world today, once depended on welfare to survive.

And Tim Ferris, bestselling author of “The 4-Hour Work Week” was rejected 25 times before finding a publisher, who would work with him.

Even the most horrific Halloween stories have nothing on entrepreneurs’ sagas about “The Struggle.”

Continue reading %October’s Editorial Theme: The Struggle%

Synchronizing Offline App Data with PouchDB

Fr, 2015-09-25 15:00

Applications which can work online and offline are an advantage to mobile users. For example, someone traveling by air generally has no internet connection. With a well designed app they can still work in offline mode and synchronize the offline data with an application server.

How Does This Work?

When the application is offline, the data is stored using HTML 5 local storage and session storage objects to store data in the browser or WebView. When the application is online, its programming logic will synchronize changes to a central database.

Continue reading %Synchronizing Offline App Data with PouchDB%

Should You Be Brave with Your Typography? Ask Mr. Robot.

Fr, 2015-09-25 01:56

About five years ago Julian Hansen published a brilliant flowchart poster called 'So You Need a Typeface'. Answer a series of simple 'yes/no' questions and Julian will point you to the font you need. While the poster is a little tongue-in-cheek, it gives you an idea of how complex font selection can be. Someone once […]

Continue reading %Should You Be Brave with Your Typography? Ask Mr. Robot.%

Creating and Handling Forms in Node.js

Do, 2015-09-24 20:00

Web applications commonly have to handle forms in which the user can enter data that need to be processed. Node.js by itself does not provide any way to handle the work required to process the data of the form (like validations, for example). It just provides raw body data. This might get cumbersome for the app developer to manage, but there are third party modules which can help process the form data and provide the necessary ones to the application. Among these modules, there’s one called formidable; it deals with a Node.js module which can help you parse form data and use them in your application.

In this article we’re going to see how we can use the formidable module to process form fields and files in our Web application.

Continue reading %Creating and Handling Forms in Node.js%

Watch: Using Modernizr CSS Classes

Do, 2015-09-24 17:30

In this video I’ll introduce you to how Modernizr can help you style your website's CSS based on the current browser's feature support.

Modernizr will add all the results of the detected features as classes to the html element. In this lesson we’ll target browsers that support emoji and turn a boring bullet list into a fun emoji list. After watching this screencast you’ll have a basic understanding of how to use Modernrizr's CSS classes to conditionally style elements on your page. The code sample for this lesson can be found at on GitHub.

This is one lesson from SitePoint Premium's latest course A Beginners Guide to Modernizr 3. If you enjoyed this video and want to see more, come and check out the rest of the course.

Loading the player...

Continue reading %Watch: Using Modernizr CSS Classes%

Simple Rails Authentication with Clearance

Do, 2015-09-24 14:00

During the past month I have covered various authentication solutions for Rails. This article is the fifth in the series (oh my) and our guest today is Clearance.

Clearance is an opinionated e-mail/password-based authentication and authorization solution for Rails created by Thoughtbot Inc (the guys who created FactoryGirl, PaperClip and other cool libraries). Clearance is designed as a Rails engine. It is intended to be small, simple, and well-tested. In a sense, it is similar to Devise in that Clearance has many defaults to help you get started in nearly five minutes, and all those defaults can be easily overridden. In contrast to Devise, however, Clearance presents only minimal functionality that can be customized further as you see fit.

This solution is actively maintained, so I really recommend trying it out. In this article I will demonstrate how to integrate Clearance, restrict access, customize it, and use additional checks during sign-in.

Source code can be found on GitHub.

Working demo is available at sitepoint-clearance.herokuapp.com.

Preparations

To start off, create a new Rails app under a codename "Clear Sky":

$ rails new ClearSky -T

For this demo Rails 4.2 will be used, but Clearance is compatible with Rails 3.2, as well.

Continue reading %Simple Rails Authentication with Clearance%

SQL vs NoSQL: How to Choose

Mi, 2015-09-23 22:00

In the previous article we discussed the primary differences between SQL and NoSQL databases. In this follow-up, we'll apply our knowledge to specific scenarios and determine the best option.

To recap:

SQL databases:

  • store related data in tables
  • require a schema which defines tables prior to use
  • encourage normalization to reduce data redundancy
  • support table JOINs to retrieve related data from multiple tables in a single command
  • implement data integrity rules
  • provide transactions to guarantee two or more updates succeed or fail as an atomic unit
  • can be scaled (with some effort)
  • use a powerful declarative language for querying
  • offer plenty of support, expertise and tools

NoSQL databases:

  • store related data in JSON-like name-value documents
  • can store data without specifying a schema
  • must usually be denormalized so information about an item is contained in a single document
  • should not require JOINs (presuming denormalized documents are used)
  • permit any data to be saved anywhere at anytime without verification
  • guarantee updates to a single document -- but not multiple documents
  • provide excellent performance and scalability
  • use JSON data objects for querying
  • are a newer, exciting technology

SQL databases are ideal for projects where requirements can be determined and robust data integrity is essential. NoSQL databases are ideal for unrelated, indeterminate or evolving data requirements where speed and scalability are more important.

Continue reading %SQL vs NoSQL: How to Choose%

Hints Creation with EnjoyHint

Mi, 2015-09-23 20:00

The aim of this article is to cover the process of creating hints for a website. Firstly, we'll take a look at how we can create a single hint for a proper website element. Then, we’ll create a sequence of hints to make a guided tour of a website. To create the hints I'll use EnjoyHint. As an example, I’ve made a simple demo using the Bootstrap framework.

EnjoyHint depends on jQuery and it requires a version of the library grater than or equal to version 1.7. Another dependency is KineticJS v5.1.0 which is already included into EnjoyHint, so there’s nothing to worry about.

If you want to check out the source code of the demo, you can visit this GitHub repository.

Why Using EnjoyHint?

EnjoyHint’s main goal is to give you an opportunity to help a user in finding his way through your web pages features. It can be pretty useful in case of a big web application with tons of elements.

You can highlight a single element and add a description to it, or take a user by the hand to show him all the available features one by one. With this library is also possible to change the shape of the highlighted area or to use your own style for the hint text. Here’s a list of its key features:

  • Free to use
  • Automatic focus and highlighting of the area related to the hint
  • Different shapes of the highlighted area
  • Hint delay property
  • Possibility to resume the interrupted hint sequence
  • Cross-browser support
  • Support for Android, iOS, and Windows touch screens

With this in mind, it’s now time to write some code to see this library in action.

Continue reading %Hints Creation with EnjoyHint%

Building a WordPress Carousel Plugin: Part 3

Mi, 2015-09-23 18:00

Without styling, the WordPress carousel we've built in the first part of this tutorial is just a list of items, but it is at least useful, in the sense that they're all visible. The CSS we added in part two of this tutorial enhanced the display of the carousel, but now the problem is that only the first item is shown to the user and there's no way to display the rest of the items.

We added arrows to our carousel, to allow the user to navigate between the different items, and now it's time to make them usable, with a bit of JavaScript.

In the continuation of this tutorial, we'll learn how to properly include our script, then we'll write a script that will launch a function which animates the items when the user hits an arrow.

Linking a JavaScript File

Here we'll use JavaScript to make our arrows useful. As for the CSS part, create a new file. I called it carousel.js and placed it in the root of the plugin's folder.

We need to indicate to WordPress that we are using the JavaScript file. To do this, we'll use the wp_enqueue_script() function.

Continue reading %Building a WordPress Carousel Plugin: Part 3%

jQuery Foundation Web Excellence Program – Powered by jQuery

Mi, 2015-09-23 16:27
Snowball: A Tool for Storytelling on the Web


openHTML Research Group

Tell us about your organization

Our openHTML group at Drexel University in Philadelphia, PA researches how people learn about computation through the web, and ways we can design tools to support these learning experiences. Snowball is our latest project for giving people a way to express themselves using the web as a medium.

What is Snowball and how does it help advance the Open Web?

Snowball is a WordPress plugin that makes it possible for anyone to create modern, immersive, interactive articles to tell their stories on the web. Our goal is to make it possible for everyone including bloggers, students, and journalists to create engaging articles like the ones produced by world-class news organizations.

We provide a graphical interface where you can start building the content of your article block by block. Within each block, you can tinker with the widgets to add your own content and style. Each block also has a coding interface so you can inspect the underlying HTML and CSS, and add a dash of your own to customize even further. We provide blocks ranging from third-party media embeds to interactive visualizations.

What are the benefits of including jQuery as a dependency in Snowball?

jQuery ensures that we can provide a uniform experience across a broad range of devices and platforms, freeing our time to spend on what makes our project unique.

How do jQuery projects help Snowball and its users achieve your and their goals?

jQuery has accelerated the pace of our development, allowing us to build a functional prototype in less than two months. In turn, this has allowed us to start getting feedback, and iterating on our design, sooner rather than later.

What’s coming next in Snowball?

We’re partnering with The Triangle, Drexel University’s student-run newspaper, to pilot Snowball for long-form articles. This will teach us a great deal about how journalists work the web and how we can make our tool more useful for them. We’re also in the process of getting Snowball listed on WordPress.org’s plugin directory so that it’s available to everyone.

How can people get involved?

If any news organization or educators are interested in trying Snowball, we’d love to partner with you. We’re also open source and on GitHub. If you know HTML, CSS, and jQuery, you know enough to contribute new block types in Snowball!

Are you involved with an amazing site or app that uses a jQuery Foundation project or projects? Check out the Web Excellence Program categories and submit yours today! Entries in all categories are heartily welcomed, and we’d love to hear how individual developers all the way to Enterprises use jQuery Foundation projects to achieve their business and technology goals.

Demystifying RegEx with Practical Examples

Mi, 2015-09-23 16:00

A regular expression is a sequence of characters used for parsing and manipulating strings. They are often used to perform searches, replace substrings and validate string data. This article provides tips, tricks, resources and steps for going through intricate regular expressions.

There are many books, articles, websites and the PHP official documentation that explain regular expressions, so instead of writing another explanation I’d prefer to go straight to more practical examples. You can find a useful cheat sheet at this link.

Along with a host of useful resources, there is also a conference video by Lea Verou at the bottom of this post - it’s a bit long, but it’s excellent in breaking down RegEx.

How to Build a Good Regex

Regular expressions are often used in the developer’s daily routine - log analysis, form submission validation, find and replace, and so on. That’s why every good developer should know how to use them, but what is the best practice to build a good regex?

1. Define a Scenario

Using natural language to define the problem will give you a better idea of the approach to use. The words could and must, used in a definition, are useful to describe mandatory constraints or assertions.

Below is an example:

  • The string must start with ‘h’ and finish with ‘o’ (e.g. hello, halo).
  • The string could be wrapped in parentheses.
2. Develop a Plan

After having a good definition of the problem, we can understand the kind of elements that are involved in our regular expression:

  • What are the types of characters allowed (word, digit, new line, range, …)?
  • How many times must a character appear (one or more, once, …)?
  • Are there some constraints to follow (optionals, lookahead/behind, if-then-else, …)?

Continue reading %Demystifying RegEx with Practical Examples%

How Pointer Events Will Make Cross-Browser Touch Support Easy

Mi, 2015-09-23 15:30

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

I often get questions from developers like, “with so many touch-enabled devices on phones and tablets, where do I start?” and “what is the easiest way to build for touch-input?” Short answer: “It’s complex.” Surely there’s a more unified way to handle multi-touch input on the web – in modern, touch-enabled browsers or as a fallback for older browsers. In this article I’d like to show you some browser experiments using Pointers – an emerging multi-touch technology and polyfills that make cross-browser support, well less complex. The kind of code you can also experiment with and easily use on your own site.

First of all, many touch technologies are evolving on the web – for browser support you need to look the iOS touch event model and the W3C mouse event model in additional to at MSPointers, to support all browsers. Yet there is growing support (and willingness) to standardize. In September 2012, Microsoft submitted MSPointers to the W3C for standardization and in February 2015, we’ve reached W3C Recommendation: http://www.w3.org/TR/pointerevents. The MS Open Tech team also released an initial Pointer Events prototype for Webkit and recently, Mozilla has announced support for Pointer Events in Firefox Nightly!

The reason why I experiment with Pointer Events is not based on device share – it’s because Microsoft’s approach to basic input handling is quite different than what’s currently available on the web and it deserves a look for what it could become. The difference is that developers can write to a more abstract form of input, called a “Pointer.” A Pointer can be any point of contact on the screen made by a mouse cursor, pen, finger, or multiple fingers. So you don’t waste time coding for every type of input separately.

[author_more]

If you’re running IE10, you’ll need to prefix the API or use our polyfill library Hand.js. You’ll find the original article with prefixes here: Unifying touch and mouse: how Pointer Events will make cross-browsers touch support easy

The Concepts

We will begin by reviewing apps running inside Internet Explorer 11, Microsoft Edge, or Firefox Nightly which exposes the Pointer Events API and then solutions to support all browsers. After that, we will see how you can take advantage of IE/MS Edge gestures services that will help you handling touch in your JavaScript code in an easy way. As Windows 8.1/10 and Windows Phone 8.1/Mobile 10 share the same browser engine, the code & concepts are identical for both platforms. Moreover, everything you’ll learn on touch in this article will help you do the very same tasks in Windows Store apps built with HTML5/JS, as this is again the same engine that is being used.

The idea behind the Pointer is to let you addressing mouse, pen & touch devices via a single code base using a pattern that match the classical mouse events you already know. Indeed, mouse, pen & touch have some properties in common: you can move a pointer with them and you can click on element with them for instance. Let’s then address these scenarios via the very same piece of code! Pointers will aggregate those common properties and expose them in a similar way than the mouse events.

Continue reading %How Pointer Events Will Make Cross-Browser Touch Support Easy%

Using XAML Controls to Design Windows Phone Apps

Mi, 2015-09-23 15:00

Building an app is a cool thing to know, but it may not be easy for everyone. I try to keep articles as simple as possible so that everyone can understand, even those who are on their first day programming. There’s no need to feel shy if you don’t know much yet! Don’t get mad at yourself, everything will come one step at a time.

With this in mind, I decided to write an article about how to build a simple Windows Phone app with little coding knowledge.

If you are wondering How can I build an app without writing any code?, the answer is by designing it. In my opinion it’s easier to learn how to design first, and then add the code to connect the elements logically. With the tools offered today, it’s as simple as drag and drop.

Visual Studio has lots of XAML controls ready to use for designing a beautiful new app. Let’s get started.

Continue reading %Using XAML Controls to Design Windows Phone Apps%

7 Fantastic Plugins to Level-up Your Sketch App Powers

Mi, 2015-09-23 14:00

Some days I find myself wondering whether the core fundamentals of Sketch App can even be improved by plugin functionality. Sketch App is a breeze to use because its features are minimal.

As true as that may be, it doesn’t mean that we can’t extend its usefulness here and there with Sketch App plugins. In this article, I’ll talk about managing plugins with the Sketch Toolbox and a few of my everyday favourites. Let's start with the Sketch Toolbox.

Managing Plugins with Sketch Toolbox

If you don’t already have it, download the Sketch Toolbox, which is a separate Mac App created by Shahruz Shauka that manages plugins for Sketch. If you've used Sublime extensions or Atom packages, Sketch Toolbox should feel familiar.

It offers an incredibly straightforward way of installing and uninstalling Sketch plugins from its own curated database of awesome add-ons.

[caption id="attachment_115576" align="aligncenter" width="800"] Sketch Toolbox [/caption]

Plugins that Can Significantly Speed Up Your Workflow

Some of these Sketch plugins can be activated with nothing more than a keyboard shortcut, whereas others require a little more explanation. One of those is AEIconizer, which copies your icon design artboard and creates multiple iOS-ready clones - the name has always baffled me, but its effectiveness is outstanding.

Chances are you currently use of Smart Objects when designing iOS icons in Photoshop. Sketch App doesn’t have that functionality (maybe because it can hinder performance), so search for and install “AEIconizer” with Sketch Toolbox, and then use command+shift+i while actively focusing on a square artboard of any size. We now have our icon design in 14 different sizes.

If you decide to make a change to the design (now labelled as “Icon-Original”), simply run that keyboard shortcut again.

Nifty.

[caption id="attachment_115575" align="aligncenter" width="800"] AEIconizer[/caption]

Sketch Commands is another keyboard shortcut tool that adds a colossal amount of convenient keypresses to Sketch App’s already well-stocked repertoire. Perform a huge raft of tasks from rapid-selecting to applying intricate image effects with nothing more than a few keyboard taps.

Content Generator doesn’t have any shortcuts associated with it, but you can select a layer (or multiple similar layers), navigate to Plugins → Content Generator Sketch Plugin from the menu bar, and then choose anything from locations, e-mail addresses, names, images, 'time ago' dates and 'lorem ipsum'.

Plugins that Collaborate with Apps You Already Use

Facebook Origami, Slack, FramerJS, Zeplin and Marvel App are some very well-known and critically-acclaimed tools that many of us designer folk could not survive without, so it’s almost inevitable that these plugins exist to help bridge the gap between these epic mostly-prototyping tools and Sketch App.

Continue reading %7 Fantastic Plugins to Level-up Your Sketch App Powers%

5 Successful Email Newsletters You Can Learn From

Di, 2015-09-22 21:00

Starting a newsletter is pretty easy, thanks to tools like Mailchimp, Benchmark Email, and Constant Contact. But starting a newsletter that people actually want to read? That’s much harder. First, we’ll show you five examples of well-executed email newsletters. Then, we’ll dive into which model is best for your specific goals and product. Example 1: […]

Continue reading %5 Successful Email Newsletters You Can Learn From%

Debug WebGL and HTML5 Mobile Experiences with Visual Studio Emulators

Di, 2015-09-22 20:00

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

With the recent availability of Visual Studio 2015 RTM came the free Visual Studio Emulator for Android. In this article, I’ll show you how to test your WebGL experiences on these very fast Android emulators.

First, download Visual Studio 2015 RTM (such as the free community edition) or install the Android emulators directly without Visual Studio. Then, read Introducing Visual Studio’s Emulator for Android, which explains how this cool emulator works and the features supported.

Note: I recently published an article describing how to remotely debug and profile the performance of HTML5 websites and apps on Windows Phone. You can now use the same approach to debug Windows Mobile 10 and Mobile Edge with the release of the Windows 10 SDK Tools.

[author_more]

WebGL testing

Once installed, you can launch the tool:

And choose the image you’re interested in:

Let’s choose “5" Lollipop (5.0) XXHDPI Phone – Similar to Samsung Galaxy S4” and press play. If it’s the first time you’re launching the emulator, it will configure the Hyper-V network settings for you.

Once started, launch the default installed browser and try, for instance, to navigate to http://www.babylonjs.com/, the best available WebGL framework to date . If you try to launch one of our scenes, you’ll see an error:

Indeed, the default browser shipped with this Lollipop image doesn’t support WebGL. We need to install Chrome on it.

Search for an x86 version of the Chrome APK such as this one: Chrome 43.0.2357.93 (x86) and drag’n’drop the APK directly into the emulator. It should install it:

Continue reading %Debug WebGL and HTML5 Mobile Experiences with Visual Studio Emulators%

My Current HTML Email Development Workflow

Di, 2015-09-22 19:00

Each one of us has our own approach to web development: a preferred editor, some helper tools, a personal project flow, and so on. When we deal with big or complex projects, it is essential to have a clear development path, to both save time and minimize errors.

In my experience, this is especially important when working on an HTML email project. Email requires so many repetitive tasks that are not particularly complex in themselves (not very often, at least), but which can become problematic because of the sheer number of elements and tasks that need to be checked.

Here I’ll try to explain my personal workflow for HTML email development. I hope it’s useful for you to cherry-pick the parts you like.

A Typical Email Development Workflow

A classic email development workflow has three primary steps (see my Crash course article for more details):

  • Authoring (with preliminary local testing)
  • CSS inlining
  • Testing

The final testing (with inlined CSS) is the step that requires more time since we’ll probably have to repeat it many times. Moreover, the “CSS inlining” and “Testing” tasks require a little extra work and attention: first, you’ll have to take care of preserving your original working copy from the inlined one. Also, the final testing requires you to send your inlined HTML to various accounts to check your design against various email clients.

Sending your code by email is a little tricky, since most clients don’t allow you to compose an email by pasting HTML code in its body (the only one I know is Thunderbird). But every test requires many actions to compose the mail, inline the CSS, paste the code, etc.

If you have a testing platform account (Litmus, Email On Acid, Campaign Monitor or some other), you can simplify the final testing task by submitting your inlined code to the test platform but in order to perform a more accurate test, you’ll still have to send them your code by mail. In the past, I used a little PHP script to send the test emails, which could save some time, but it still requires repeating certain tasks.

Going back to CSS, you’ll probably have to deal with two files: one to be inlined and one to be embedded (for the clients that support media queries).

You’ll have to edit the CSS to be inlined directly into your HTML file, then launch an inliner tool (the Mailchimp inliner, for example), and finally you have to embed the second CSS into the inlined file (It bores me just writing about it!).

We can now review our workflow scheme in a more detailed way:

To get a real productive workflow, many issues are still unresolved, and repetitive steps are significantly above the creative ones, which rarely leads to a good job.

Luckily, we still have some cards to play: Preprocessors and task runners.

Adding HTML and CSS Preprocessors

When I began to use preprocessors, I immediately realized how they could be useful for email development. The need for extremely verbose code (especially for HTML), can be easily simplified by a preprocessor, both for HTML and for CSS.

I mostly use Jade for HTML and Less for CSS, but you can choose the technologies you prefer. Jade is really useful when dealing with repetitive and confusing code, like nested tables. Take a look at the following sample of a three-level deep table.

[code language="html"]
<table width="100%" id="wrapper">
<tbody>
<tr>
<td width="100%">
<table align="center" class="header">
<tbody>
<tr>
<td width="100%">
<table width="100%">
<tbody>
<tr>
<td>cell 1</td>
<td>cell 2</td>
<td>cell 3</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
[/code]

The Jade lines that produce the same code are as follows:

[code language="jade"]
table(width="100%" id="wrapper")
tbody
tr
td(width="100%")
table(class="header" align="center")
tbody
tr
td(width="100%")
table(width="100%")
tbody
tr
td cell 1
td cell 2
td cell 3
[/code]

As you can see, there are no more problems with unclosed tags and the code is easy to read.

Using Jade you can create complex templates and build your own snippets library, reusing your code in more projects. You can do the same with Less or Sass.

You can compile your files with Gulp or Grunt, but in order to have a quick preview of you work, I’ve found that the best solution is offered by Coda and CodeKit.

Continue reading %My Current HTML Email Development Workflow%