Skip to content
Language templates used to render example HTTP calls in different languages
Branch: master
Clone or download
abtris Merge pull request #40 from apiaryio/kylef/java-rel-path
[Java Code Example] Fix an issue with relative paths
Latest commit 35931e1 Jun 9, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore _site to .gitignore May 30, 2013
csharp.html Fixed language rendering failing in case of null body Feb 5, 2015
php.html Hardening templates for missing @Body Sep 1, 2013
python.html Fixing rendering of cURL multiline body, new-lines in PHP and Python,… Jan 30, 2013
ruby.html Fix rubyKey, because it was changing dashes into underscore in whole … Nov 26, 2013
vb.html Formatting for one-header-per-line Aug 8, 2014

This repository lists language templates used to power code samples in Apiary's API Documentations. Please feel free to contribute your own languages or improve the existing ones.

You can try-out your code at Language Templates Playground.


The HTML templates are written in ECT, which places data between <%= and %> tags and control structures between <% and %>. The following are variables and helper methods you can use when rendering the code for a request:

  • @headers - HTTP headers to be sent
  • @body - HTTP body to be sent
  • @method - HTTP method used in the request
  • @url - URL of the request, relative to the root of the server (starting with '/')
  • @apiUrl - Hostname of the API mock/proxy server (including http/https, not including trailing '/')
  • @contentType - A shorthand for @headers['content-type']
  • @helpers.escape - escape " (double-quote) characters
  • @helpers.rubyKey - helper that produces content_type out of Content-Type
  • @helpers.getContentType(headers) - same as @contentType but in form of a function you can pass any array of headers
  • @helpers.getContentTypeBrush(headers) - produces a CSS class that enabled syntax-highlighting for this language
  • @helpers.isNotEmpty (obj) - same like [].length != 0 for objects (hash maps)
You can’t perform that action at this time.