Skip to content

Instantly share code, notes, and snippets.

@zookzook
Created March 7, 2020 14:57
Show Gist options
  • Select an option

  • Save zookzook/f5f59cb21aff3e3b7f60c51f2198ed55 to your computer and use it in GitHub Desktop.

Select an option

Save zookzook/f5f59cb21aff3e3b7f60c51f2198ed55 to your computer and use it in GitHub Desktop.
Hocon-Decode-Example
iex(9)> Hocon.decode(File.read!("./hocon/index.conf"))
{:ok,
%{
"pars" => [
%{
"text" => "|## Introduction ##\n |\n |Phoenix is not only an excellent web framework, but also it can be transformed with a few steps into a\n |static content generator. You need some programming knowledge, so this way is\n |rather something for developers.\n |\n |Usually a static content generator is a system that reads a text document with a few\n |meta-information such as author, date, title and a markdown block to produce\n |HTML files, which can be uploaded to a web server.\n |\n |There are a lot of existing solutions for this, so why would you create a new system\n |develop? Let's take a look at the current limits. Maybe we can find this something\n |to the back.\n |\n |### text documents ###\n |Usually, the structure of a document is rigid and simple: a text file describes few elements:\n |* title\n |* date\n |* text header\n |* markdown block\n |\n |What if you have several different structures? For example, a left and right side?\n |Several pictures per paragraph? Where can these elements be placed? For such situations\n |the simple text file is no longer sufficient.\n |\n |You could use JSON or XML files instead of the text file.\n |But these are usually more complex with a text editor than a simple text file.\n |Fortunately there is a solution [HOCON](https://github.com/lightbend/config/blob/master/HOCON.md),\n |which we're going to take a closer look at now.\n |"
},
%{
"text" => "|## HOCON - Human-Optimized Config Object Notation ##\n |\n |Dieses Text-Format ist eine Obermenge von JSON, wobei das Format für den Anwender ausgelegt wurde.\n |\n |Beispiel\n |<script src=\"https://gist.github.com/zookzook/56d91e7baed3464888a9b5985ab47aae.js\"></script>"
}
],
"title" => "Using Phoenix Webframework as static content generator"
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment