Skip to content

Getting Dv and Templater to Freeze Lists into Html

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
%>

Comments