#+title: Babel in Jsonnet with ~ob-jsonnet.el~ #+date: 2021-10-08 #+hugo_base_dir: ../../.. #+hugo_section: posts #+hugo_bundle: ob-jsonnet #+export_file_name: index #+hugo_draft: false #+hugo_tags: emacs jsonnet org #+hugo_categories: tools #+audience: both #+visibility: public #+property: header-args+ :eval never-export I made some ~org-babel~ functions for Jsonnet and it was pretty easy! #+hugo: more [[https://git.sr.ht/~bzg/worg/tree/master/item/org-contrib/babel/ob-template.el][ob-template.el]] is a great starting point and made for light work. * Install :PROPERTIES: :CUSTOM_ID: install :END: Download [[https://raw.githubusercontent.com/brettviren/ob-jsonnet/master/ob-jsonnet.el][~ob-jsonnet.el~]] to somewhere in your load path and add #+begin_src lisp (require 'ob-jsonnet) #+end_src And append ~(jsonnet . t)~ to ~org-babel-load-languages~. You may customize ~org-babel-jsonnet-command~ if the ~jsonnet~ command is not in your ~$PATH~. * Examples :PROPERTIES: :CUSTOM_ID: examples :END: Basic usage #+begin_example ,#+begin_src jsonnet :exports both :wrap "src json" {a:42} ,#+end_src #+end_example #+begin_src jsonnet :exports results :wrap "src json" {a:42} #+end_src #+RESULTS: #+begin_src json { "a": 42 } #+end_src You can also supply command line options: #+begin_example ,#+begin_src jsonnet :cmdline "-S" :exports both :wrap "example" std.join(" ", ["hello","world"]) ,#+end_src #+end_example #+begin_src jsonnet :cmdline "-S" :exports results :wrap "example" std.join(" ", ["hello","world"]) #+end_src #+RESULTS: #+begin_example "hello world" #+end_example Now, if only we had proper syntax highlighting for Jsonnet in Hugo.