LDkit

variable sparql
import { sparql } from "https://deno.land/x/ldkit/sparql.ts";

A template tag for SPARQL queries or its parts. Automatically converts values to SPARQL literals and escapes strings as needed.

Examples

Example 1

import { sparql } from "ldkit/sparql";
import { DataFactory } from "ldkit/rdf";

const df = new DataFactory();
const quad = df.quad(
  df.namedNode("http://example.org/s"),
  df.namedNode("http://example.org/p"),
  df.literal("o"),
);
const query = sparql`SELECT * WHERE { ${quad} }`;
console.log(query); // SELECT * WHERE { <http://example.org/s> <http://example.org/p> "o" . }

type

(strings: TemplateStringsArray, ...values: SparqlValue[]) => string