FTD is an open source programming language for writing prose.
ftd
Hello World!-- import: lib -- lib.h1: Hello World
lib
, and has a heading of level 1, “Hello World”. FTD language is designed for human beings, not just programmers, we have taken precautions like not requiring quoting for strings, not relying on indentation nor on braces that most programming languages require. It is not verbose like HTML, and not simplistic like Markdown. FTD can be compared with Markdown, but in FTD you can do the following for example:
ftd.text
kernel component-- boolean $current: true -- ftd.text: Hello World! align: center $on-click$: toggle $current padding: 20 text-align: center color if { current } : $inherited.colors.cta-primary.base color: $inherited.colors.cta-primary.text background-color: $inherited.colors.text
toggle
, which can be used to create simple event handling. You can also abstract out the logic in a custom ftd component, eg:
-- ftd.text toggle-text: $title boolean $current: false caption title: $on-click$: toggle $current text-align: center color if { current }: $inherited.colors.cta-primary.base color: $inherited.colors.cta-primary.text background-color: $inherited.colors.text padding: 20 -- toggle-text: FTD is cool!
toggle-text
, and then instantiated it instead. This way we can create custom component library and use them in our writing without “polluting” the prose with noise. FTD is also a good first class data language. You can define and use records:
ftd
-- record person: caption name: string location: optional body bio:
caption
is an alias for string
, and tells ftd that the value can come in the “caption” position, after the :
of the “section line”, eg lines that start with --
or ---
. If a field is optional, it must be marked as such.-- person amitu: Amit Upadhyay location: Bangalore, India Amit is the founder and CEO of FifthTry. He loves to code, and is pursuing his childhood goal of becoming a professional starer of the trees.
amitu
. You can also define a list:-- person list employees: -- person: Sourabh Garg location: Ranchi, India -- person: Arpita Jaiswal location: Lucknow, India Arpita is the primary author of FTD language. -- end: employees
-- render-person: person: $p $loop$: $employees as $p
ftd
files#[derive(serde::Deserialize)] struct Employee { name: String, location: String, bio: Option<String> } let doc = ftd::p2::Document::from("some/id", source, lib)?; let amitu: Employee = doc.get("amitu")?; let employees: Vec<Employee> = doc.get("employees")?;
FTD can also be used as a configuration language.
Github: https://github.com/FifthTry/ftd
Discord: Join our ftd
channel.
License: BSD