YAML, HAML, RAML, and…?

yaml_logo

I know YAML as I was using this for a while, but recently I came across HAML and RAML. Even though they sound similar technologies actually they are not. Below are some info:

 

YAML: YAML (“YAML Ain’t Markup Language”) is a flexible, human readable file format that is ideal for storing object trees.

The design goals for YAML are, in decreasing priority: 

  1. YAML is easily readable by humans.
  2. YAML data is portable between programming languages.
  3. YAML matches the native data structures of agile languages.
  4. YAML has a consistent model to support generic tools.
  5. YAML supports one-pass processing.
  6. YAML is expressive and extensible.
  7. YAML is easy to implement and use.

(Source)

Note:

  • YAML file extensiopn should be .yml
  • Tabs NOT allowed, but spaces.
  • Case-sensitive
  • Indent properties with space (i.e – myName NOT -myName)

YAML Validator/Converter : http://codebeautify.org/yaml-validator

Examples:

 

name : Sanj
Phone: 123444322 
address:
- Address Line 1
- Address Line2
- London

Array Type: {C# : 80, Python : 85, Javascript : 90}

When you convert this to JSON you’ll get

{
  "name": "Sanj",
  "Phone": 123444322,
  "address": [
    "Address Line 1",
    "Address Line2",
    "London"
  ],
  "Array Type": {
    "C#": 80,
    "Python": 85,
    "Javascript": 90
  }
}

Convert YAML to XML

<?xml version="1.0" encoding="UTF-8" ?>
<root>
    <name>Sanj</name>
    <Phone>123444322</Phone>
    <address>Address Line 1</address>
    <address>Address Line2</address>
    <address>London</address>
    <Array Type>
        <C#>80</C#>
        <Python>85</Python>
        <Javascript>90</Javascript>
    </Array Type>
</root>

haml

HAML: Haml (HTML Abstraction Markup Language) is a lightweight markup language that is used to describe the HTML of a web document. It is used to cleanly and simply describe the HTML of any web document, without the use of inline code. Haml functions as a replacement for inline page templating systems such as PHP, ERB, and ASP. However, Haml avoids the need for explicitly coding HTML into the template, because it is actually an abstract description of the HTML, with some code to generate dynamic content.

Web site: http://haml.info/

Example:

!!!
%html
 %head
 %title Simple HAML Example
%
 .main_title This is my first HAML code
 %ul.nav
 %li
 %a(href="/") Home
 %li
 %a(href="/about-me/") About me
 %li
 %a(href="/contact/") Contact

 
 %footer
 %p Copyright &copy; #{Time.now.year} Sanj.

..and the output would be

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>Simple HAML Example</title>
  </head>
</html>
<div>
  <div class="main_title">This is my first HAML code
    <ul class="nav"></ul></div>
  <li>
    <a href="/">Home</a>
  </li>
  <li>
    <a href="/about-me/">About me</a>
  </li>
  <li>
    <a href="/contact/">Contact</a>
    <footer>
      <p>Copyright &copy; #{Time.now.year} Sanj.</p>
    </footer>
  </li>
</div>

raml

RAML: RAML (RESTful API Modeling Language) is a YAML-based language for describing RESTful APIs. It provides all the information necessary to describe RESTful or practically-RESTful APIs. It is highly readable by both humans and computers.

Web site: raml.org

Examples :  http://docs.raml.org/apis/instagram/