background preloader

Janl/mustache.js

Janl/mustache.js
Related:  Scripting

Using CORS Introduction APIs are the threads that let you stitch together a rich web experience. But this experience has a hard time translating to the browser, where the options for cross-domain requests are limited to techniques like JSON-P (which has limited use due to security concerns) or setting up a custom proxy (which can be a pain to set up and maintain). Cross-Origin Resource Sharing (CORS) is a W3C spec that allows cross-domain communication from the browser. By building on top of the XMLHttpRequest object, CORS allows developers to work with the same idioms as same-domain requests. The use-case for CORS is simple. As you can see from this example, CORS support requires coordination between both the server and client. Making a CORS Request This section shows how to make a cross-domain request in JavaScript. Creating the XMLHttpRequest object CORS is supported in the following browsers: Chrome, Firefox, Opera and Safari all use the XMLHttpRequest2 object. Event handlers withCredentials Resources

mustache(5) -- Logic-less templates. mustache(5) Mustache Manual mustache(5) mustache - Logic-less templates. A typical Mustache template: Hello {{name}} You have just won {{value}} dollars! {{#in_ca}} Well, {{taxed_value}} dollars, after taxes. {{/in_ca}} Given the following hash: Will produce the following: Hello Chris You have just won 10000 dollars! Mustache can be used for HTML, config files, source code - anything. We call it "logic-less" because there are no if statements, else clauses, or for loops. Tags are indicated by the double mustaches. Variables The most basic tag type is the variable. All variables are HTML escaped by default. You can also use & to unescape a variable: {{& name}}. By default a variable "miss" returns an empty string. Template: * {{name}} * {{age}} * {{company}} * {{{company}}} Hash: Output: Sections Sections render blocks of text one or more times, depending on the value of the key in the current context. A section begins with a pound and ends with a slash. False Values or Empty Lists Shown. Shown. Why?

StringTemplate RESTful services with jQuery and Java using JAX-RS and Jersey NOTE: This is the Java version of this article and its companion app. A PHP version is available here. This is a more in depth version of my previous post on the same topic. The previous article only covered the HTTP GET method for building RESTful services. GET to retrieve and search dataPOST to add dataPUT to update dataDELETE to delete data The application used as an example for this article is a Wine Cellar app. You can run the application here. Implementing the API using JAX-RS JAX-RS makes it easy to implement this API in Java. Quick look at the JAX-RS annotations used in this class: @GET, @POST, @PUT, @DELETE: HTTP method the class method responds to. The jQuery client below sends data to the server using JSON (addWine() and updateWine() methods). The approach you use to actually retrieve the data is totally up to you. Testing the API using cURL If you want to test your API before using it in a client application, you can invoke your REST services straight from a browser address bar.

The jQuery UI CSS Framework – Part 1: Intro and How To Style a Button | Fbloggs Geekdom This is the first in a series of articles on the jQuery UI CSS Framework.. This is a powerful suite of CSS selectors that you can use to build web applications with a consistent UI. The main jQuery UI demo page shows you a list of UI widgets (which are still somewhat limited in scope compared to ExtJS, for example), but it doesn’t do a very good job on selling you on the benefits of designing other UI components, or components of those widgets, using the UI CSS framework. What is the jQuery UI CSS Framework? It is a set of CSS selectors that let you design your web pages to conform to the jQuery UI widgets standards. The jQuery UI CSS Framework provide semantic presentation classes to indicate the role of an element within a widget such as a header, content area, or clickable region. (from the jQuery UI Theming documentation page). Benefits of the jQuery UI CSS Framework Here are the top benefits I think the framework has to offer: It handles difficult design issues for you. Next Article

A Lean and Mean Un-opinionated Templating Engine - CodeProject Download Clifton.Core.TemplateEngine.zip - 89.4 KB Table of Contents Introductory Rant I've fussed with the templating engine RazorEngine in conjunction with Microsoft's Razor parser and code generator and every time I fuss with it, I spend far too much time getting the NuGet dependencies working correctly, and I've never been able to get the whole ApplicationDomain thing working correctly so that I don't end up with hundreds of temporary assembly files in my bin folder. So I'm presenting you with a lean and mean template parser that simply gets the job done. Goals Simple - Let's try to write this in under 500 lines of code. Requirements We should be able to apply template parsing to any kind of text document, not just HTML. Code Blocks A code block always begins with @{ and always ends with a matching }. Literal Copy With a Code Block Inside a code block, a line of text can be copied literally using the @: syntax, for example: Hide Copy Code @: Do not interpret me as code. Variable Replacement

AngularJS, Jersey, JSP and Java EE 6 » Imifos' Lucubratory The “topro” project (short for “topic proposer”, sorry I wasn’t very inspired on this) is a test that I made to play around with AngularJS. In the opposite to a lot of AngularJS examples on the net, the project implements the entire chain: AngualarJS on the browser side, REST to communicate with the application server, JAX-RS/Jersey as server-side REST implementation, JSP as templating system of the server-side front-end, Java EE 6 for server-side back-end. The project demonstrates many different things, some of them enumerated hereunder. The choice of using JSP technology for templating may seem strange at first sight. Concerning JSP, one has to admit that, despite of its age, it’s a great and proven technology. For simplification, the project doesn’t use a database. The complete source code can be found here: Some things discussed in this project: See web.xml and eu.lucubratory.topro1.front.res.page.MainPageResource

Updating PhoneGap's ChildBrowser plugin to handle local files Recently, I have been working on an iPad sales tool application with Shawn Crowley and Marissa Christy. We are using a framework called PhoneGap to build the application. PhoneGap allows us to write the majority of the app using HTML and JavaScript. HTML and JavaScript have been excellent for 95% of the application, but these two features are more cleanly implemented using the built-in iOS widgets. Email SupportPDF Display Support It turns out that our needs for this functionality are not uncommon. Matt Kane created a github project called phonegap-plugins that solves both of these problems. Thanks for the plugins Matt, they have been a great help. We used the EmailComposer plugin to solve the email support feature and the ChildBrower plugin to solve the pdf display support feature. The ChildBrowser plugin allows external webpages to be displayed within a PhoneGap application. Client JavaScript Code: Updated ChildBrowserCommand.m:

Easy HTML Templates with Mustache Tutorial by Matt Doyle | Level: Beginner | Published on 27 April 2012 Categories: Learn how to create HTML templates using Mustache, the easy-to-use, logic-less template system. Templates are a great way to separate your website's code from its design. There are many great web template systems available for different languages and platforms, including Smarty for PHP and the Django template language for Python. In this tutorial you'll explore Mustache, a relatively new and very simple template system that you can easily use to create HTML templates. The advantages of using Mustache How to install and use the Mustache processor How Mustache tags, variables, and data objects work Using sections to create conditions and loops Including one Mustache template inside another ...and lots more! Along the way, you'll see plenty of code examples that show you how Mustache works. What is Mustache? Mustache is a simple template system that you can use when building websites and web apps. logic-less Perl:

Mustache is a JavaScript template library that helps developers work with JSON objects instead of having their data source return HTML. When you make a network call to gather data from mobile devices, it's best to keep the payload, or the return data, as small as possible. JSON, or JavaScript Object Notation, is a string of characters that can be transformed into any array to pull in data. Most of the popular social networks, including Facebook, Twitter, and foursquare, and APIs, use JSON to return data.

Mustache has a lot of other features, including logic and loops that help you easily build out a list of data with a few lines of code. by indigetal Nov 29

Je test cette lib justement ! (avec node.js mais elle a l'air d'être utilisée aussi coté client.)

franchement avec un nom comme ça c'est normal qu'elle est du succés.... by simonw Nov 26

Related: