Skip to content

Getting Dv and Templater to Freeze Lists into Html

Bram Adams
Bram Adams
1 min read

Table of Contents

v1

<%*
const dv = this.app.plugins.plugins["dataview"].api ;
const te = await dv.queryMarkdown(`TABLE resources as Resources WHERE  contains(projects, "Migration from 2022 to 2023")`)
tR += te.value
%>

reference notes for v2

<%*  
const dv = app.plugins.plugins["dataview"].api;  
const ingr = tp.frontmatter.ingredients;  
let sortedIngr = ingr.sort();  
var arr = [];  
	for (i=0; i < sortedIngr.length; i++) {  
	var name = sortedIngr[i];  
	var link = '<a href="https://bram-adams.ghost.io/' + name + '">' + name + '</a>'  
	arr.push(link);  
	}  
let dvList = dv.markdownList(arr);  
tR += dvList;  
%>

v2 (did Not compile)

<%*
const dv = this.app.plugins.plugins["dataview"].api ;
const projectsFM = tp.frontmatter.projects; // look for projects in frontmatter

console.log(projectsFM)
const projectName = "Migration from 2022 to 2023"
const arr = [];

for (let i = 0; i < projectsFM.length; i++) {
	if (projectsFM[i] === projectName) { 
		arr.push(`<a href="https://bram-adams.ghost.io/${projectsFM[i]}">${projectsFM[i]}</a>`)
	}
}

let dvList = dv.markdownList(arr);
tR += dvList;
%>

v3 (works!)

(command: templater -> replace template in modal then remove backticks -- should probably be done only on archive)

<%*
const dv = this.app.plugins.plugins["dataview"].api ;
const arr = await dv.queryMarkdown(`LIST where contains(projects, "Migration from 2022 to 2023")`)
tR += arr.value
%>
obsidianprogramming

Bram Adams

writer, programmer

Comments


Related Posts

Members Public

Issue 15: Houston, We Have a State Transition

Yes Houston, I tried jiggling the knob, that was the first thing I tried!

Issue 15: Houston, We Have a State Transition
Members Public

June 20 2023

another banger alfred workflow

June 20 2023
Members Public

How GPT Helped Me Write an e2e App From Bed (yt Assets From transcript)

What challenges can GPT overcome when combined with human laziness?

How GPT Helped Me Write an e2e App From Bed (yt Assets From transcript)