Select Transform: JSON template over JSON
Hi, my name is Ethan. I&#x27;m the creator.<p>I thought I would provide some context on why I wrote this library, and how I&#x27;m using this right now. So here it goes:<p>Other than ST.js, I also work on another open source project called Jasonette (<a href="https:&#x2F;&#x2F;www.jasonette.com" rel="nofollow">https:&#x2F;&#x2F;www.jasonette.com</a>), which lets you write an entire native iOS&#x2F;Android app in nothing but JSON markup.<p>And when you can express the entire app logic--from model to view to controller--in JSON, you can split them up whichever way you want and load them from anywhere (from a file, from cache, from a remote server, or from local memory).<p>But the biggest benefit of all is: you can load an entire ios&#x2F;android native app from the server in realtime, just like how web browsers load HTML&#x2F;JS&#x2F;CSS in realtime.<p>When working on Jasonette, implementing model and view was relatively simple. For model it&#x27;s natural since JSON is all about describing data. For view i just needed to come up with a syntax to describe layouts and all the standard mobile UI components in JSON.<p>However the biggest challenge was how do i actually describe functions in JSON. Without a function, it&#x27;s just a mockup and won&#x27;t really do anything meaningful.<p>Which brings us to ST.js.<p>When you think about what a function is, it takes one value and turns it into another. So basically what I needed to do was build something that will take one JSON, and turn it into another JSON, but most importantly I would have to do it using JSON. Basically I needed to implement a finite state machine in purely JSON.<p>And this is what templates do. So I set out to build a JSON template engine that turns one JSON into another using a template which itself is written in JSON.<p>What&#x27;s really cool about this is, since the template is JSON (As far as I know there doesn&#x27;t exist any prior art that uses JSON as a template, otherwise I would have used it instead), it has all the benefits of the JSON format itself:<p>1. You can store it anywhere (Most DBMS nowadays support JSON natively)<p>2. You can send it over the Internet<p>3. You can compose them easily<p>4. You can validate them using JSON schema<p>5. etc.<p>To use a more specific example, I use ST.js in both Android and iOS versions of Jasonette as the template engine. And a JSON template is absolutely necessary in this case.<p>For example, if I want to take a piece of device-generated data and render it, I need to be able to somehow parse it client-side (can&#x27;t send it back to server to re-generate a JSON) <a href="http:&#x2F;&#x2F;docs.jasonette.com&#x2F;templates&#x2F;#3-device-api-generated-data" rel="nofollow">http:&#x2F;&#x2F;docs.jasonette.com&#x2F;templates&#x2F;#3-device-api-generated-...</a><p>This also applies to many cases where the client-side data contains privacy-sensitive data. The only way to dynamically parse something that happens on the client side is by writing the template itself in JSON and sending it over as data.<p>Anyway, I hope you guys take a look at the examples on the homepage to get a glimpse of what makes ST.js powerful. Each example is almost its own library, except that you don&#x27;t need a separate library for those purposes since all you&#x27;re dealing with is JSON.