Quarto how-to


Teresa Kubacka


July 29, 2022

Making custom listings


  1. Create a template with an .ejs extension
  2. items stores your list items. You can loop through them. Every item has parameters corresponding to the listing fields, e.g. item.title, item.date etc. You need to wrap them in special brackets, e.g. <%= item.title %>
  3. You can define divs, spans and other elements, and add classes to them. Then you can modify the styling using css, e.g. in your main styles.css file or another file
  4. To use the template, in the listing part of the document, instead of type: default declare template: path\to\custom_listing_declaration.ejs

Merging Python and Observable

How to merge various engines in one notebook: https://gist.github.com/hrbrmstr/23355194d1964688596553a0e6a0050a

The secret is to declare the language in code such as:

print('Hello python')
# bla = {'x_values': [0,1,2,3,4], 'y_values': [10,11,12,10,9]}
bla0 = {'x_values': [0,1,2,3,4], 'y_values': [10,11,12,10,9]}
bla = []
for i in range(len(bla0['x_values'])):
  tmp = {}
  for k in bla0.keys():
    tmp[k] = bla0[k][i]
Hello python
[{'x_values': 0, 'y_values': 10}, {'x_values': 1, 'y_values': 11}, {'x_values': 2, 'y_values': 12}, {'x_values': 3, 'y_values': 10}, {'x_values': 4, 'y_values': 9}]
console.log('hello observable js')
Plot.dot(bla, {x: "x_values", y: "y_values"}).plot()