Snippet to generate today's date in YAML header of Quarto doc in VS Code using Python

40 Views Asked by At

When using Quarto in RStudio I use a snippet to generate a YAML header that prints today's date automatically using the following R code

snippet headerq
    ---
    date: "`r Sys.Date()`"
    ---

Using this headerq snippet will generate the following header:

---
date: "2024-03-03"
---

How can I achieve this same functionality when using Quarto docs in Python in VSCode?

1

There are 1 best solutions below

2
Joe On BEST ANSWER

Saving the following snippet worked exactly as needed.

{
"Quarto Header": {
    "scope": "",
    "prefix": "headerqp",
    "body": [
    "---",
    "date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE"
    ],
    "description": "Header for Quarto File"
    }