Convert Figma logo to code with AI

SilentVoid13 logoTemplater

A template plugin for obsidian

4,034
244
4,034
197

Top Related Projects

Create markdown-backed Kanban boards in Obsidian.

Simple calendar widget for Obsidian.

A data index and query language over Markdown files, for https://obsidian.md/.

Improved table navigation, formatting, and manipulation in Obsidian.md

Adds admonition block-styled content to Obsidian.md

Quick Overview

Templater is a powerful template language and engine for Obsidian, a popular note-taking and knowledge management application. It allows users to create dynamic templates with JavaScript code, enabling advanced automation and customization of notes and workflows within Obsidian.

Pros

  • Highly flexible and customizable, allowing for complex template creation
  • Integrates seamlessly with Obsidian's ecosystem
  • Supports both simple and advanced use cases, catering to users of all skill levels
  • Active development and community support

Cons

  • Requires JavaScript knowledge for advanced usage
  • Learning curve can be steep for non-programmers
  • Limited documentation for some advanced features
  • Potential for template errors if not properly configured

Code Examples

  1. Basic variable insertion:
Today's date is {{date}}
Current time is {{time}}
  1. Custom JavaScript function:
<%*
function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}
_%>
Capitalized title: <% capitalizeFirstLetter(tp.file.title) %>
  1. Conditional content:
<%*
let mood = await tp.system.prompt("How are you feeling today?");
if (mood.toLowerCase() === "happy") {
    tR += "That's great! Keep smiling!";
} else {
    tR += "I hope your day gets better soon.";
}
_%>

Getting Started

  1. Install the Templater plugin in Obsidian.
  2. Enable the plugin in Obsidian settings.
  3. Create a new template file (e.g., "daily.md") in your templates folder.
  4. Add template content using Templater syntax:
# Daily Note - {{date}}

## Tasks
- [ ] Task 1
- [ ] Task 2

## Notes
<%* let thoughts = await tp.system.prompt("Any thoughts for today?"); %>
<% thoughts %>

## Mood
<%* let mood = await tp.system.prompt("Rate your mood (1-10):"); %>
Today's mood: <% mood %>/10
  1. Use the template by running the Templater command or setting up hotkeys in Obsidian.

Competitor Comparisons

Create markdown-backed Kanban boards in Obsidian.

Pros of Kanban

  • Provides a visual, board-based project management system within Obsidian
  • Allows for easy drag-and-drop task management and organization
  • Integrates seamlessly with Obsidian's existing note-taking functionality

Cons of Kanban

  • More limited in scope, focusing primarily on task management
  • Less flexible for general-purpose templating and automation
  • May require additional setup and configuration for complex workflows

Code Comparison

Kanban (JavaScript):

createKanbanView() {
  const container = this.containerEl.children[1];
  container.empty();
  this.kanbanView = new KanbanView(this);
  container.appendChild(this.kanbanView.render());
}

Templater (TypeScript):

async create_running_config(
  template_file: TFile,
  target_file: TFile,
  run_mode: RunMode
): Promise<RunningConfig> {
  const template_content = await this.app.vault.read(template_file);
  return new RunningConfig(template_content, target_file, run_mode);
}

The code snippets demonstrate the different focuses of the two plugins. Kanban is centered around creating and rendering a visual board interface, while Templater deals with file manipulation and template processing.

Simple calendar widget for Obsidian.

Pros of Calendar Plugin

  • Provides a visual calendar interface for managing daily notes and events
  • Offers seamless integration with Obsidian's daily notes feature
  • Supports custom date formats and localization

Cons of Calendar Plugin

  • Limited to calendar-specific functionality
  • Less flexible for general-purpose templating and automation
  • May require additional plugins for advanced note manipulation

Code Comparison

Templater (JavaScript):

module.exports = {
  parse: function(content, data) {
    // Custom parsing logic
    return content.replace(/{{([^}]+)}}/g, (match, p1) => data[p1] || '');
  }
};

Calendar Plugin (TypeScript):

export default class CalendarView extends ItemView {
  constructor(leaf: WorkspaceLeaf) {
    super(leaf);
    this.registerInterval(
      window.setInterval(() => this.updateCalendar(), 1000 * 60)
    );
  }
  // ...
}

The code snippets highlight the different focus areas of each plugin. Templater emphasizes customizable templating and content manipulation, while Calendar Plugin focuses on creating and managing a calendar interface within Obsidian.

A data index and query language over Markdown files, for https://obsidian.md/.

Pros of Dataview

  • Powerful querying capabilities for Obsidian notes
  • Ability to create dynamic views and tables from note metadata
  • Extensive documentation and community support

Cons of Dataview

  • Steeper learning curve due to its query language
  • Limited templating functionality compared to Templater
  • May impact performance with large vaults or complex queries

Code Comparison

Dataview query example:

TABLE file.ctime AS "Created", file.mtime AS "Modified"
FROM "Projects"
SORT file.mtime DESC

Templater script example:

<%*
let files = tp.file.folder("Projects").sort((a, b) => b.mtime - a.mtime);
tR += "| File | Created | Modified |\n|------|---------|----------|\n";
for (let file of files) {
    tR += `| ${file.name} | ${file.ctime} | ${file.mtime} |\n`;
}
%>

Both plugins offer powerful ways to interact with and display note data in Obsidian, but they serve different primary purposes. Dataview excels at querying and displaying data, while Templater focuses on creating and manipulating notes through templates and scripts.

Improved table navigation, formatting, and manipulation in Obsidian.md

Pros of Advanced Tables Obsidian

  • Specialized focus on table management and formatting
  • Intuitive table navigation and manipulation
  • Automatic table formatting and alignment

Cons of Advanced Tables Obsidian

  • Limited to table-related functionality
  • Less versatile for general note-taking and templating
  • Smaller community and fewer extensions

Code Comparison

Advanced Tables Obsidian:

export default class AdvancedTables extends Plugin {
  async onload() {
    this.addCommand({
      id: 'insert-table',
      name: 'Insert table',
      callback: () => this.insertTable(),
    });
  }
}

Templater:

export default class Templater extends Plugin {
  async onload() {
    this.addCommand({
      id: 'insert-template',
      name: 'Insert template',
      callback: () => this.insertTemplate(),
    });
  }
}

Both plugins use similar structures for adding commands, but their functionalities differ. Advanced Tables Obsidian focuses on table-related operations, while Templater offers broader templating capabilities for various note-taking tasks.

Adds admonition block-styled content to Obsidian.md

Pros of Admonitions

  • Specialized for creating styled callout boxes in Obsidian notes
  • Offers a wide range of pre-defined admonition types with customizable icons and colors
  • Simpler to use for non-technical users who want to enhance their note-taking experience

Cons of Admonitions

  • Limited in scope compared to Templater's broader templating capabilities
  • Less flexibility for advanced users who need complex automation or scripting
  • Primarily focused on visual enhancements rather than dynamic content generation

Code Comparison

Admonitions syntax:

```ad-note
This is an example admonition.

Templater syntax:

<% tp.file.creation_date() %>
<% tp.file.folder() %>
<% tp.user.myScript() %>

Summary

Admonitions is a specialized plugin for creating visually appealing callout boxes in Obsidian, while Templater is a more powerful and flexible templating system. Admonitions is easier to use for basic note enhancement, but Templater offers broader capabilities for advanced users who need dynamic content generation and complex automation in their notes.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Templater Obsidian Plugin

templater_logo

Templater is a template plugin for Obsidian.md. It defines a templating language that lets you insert variables and functions results into your notes. It will also let you execute JavaScript code manipulating those variables and functions.

Documentation

Check out the complete documentation to start using Templater.

Warning

Templater allows you to execute arbitrary JavaScript code and system commands.

It can be dangerous to execute arbitrary JavaScript code or system commands from untrusted sources. Only run code / commands that you understand, from trusted sources.

Template Showcase / Questions / Ideas / Help

Go to the discussion tab to ask and find this kind of things.

Don't be shy and share your templates created using Templater in the Template Showcase category. Use gists to share the template file.

Resources

A list of useful resources about Templater:

Alternatives

Contributing

Feel free to contribute.

You can create an issue to report a bug, suggest an improvement for this plugin, ask a question, etc.

You can make a pull request to contribute to this plugin development.

Check this to get more information on how to develop a new internal variable / function.

License

Templater is licensed under the GNU AGPLv3 license. Refer to LICENSE for more information.

Support

If you want to support me and my work, you can sponsor me on Github (preferred method) or donate something on Paypal.

GitHub Sponsors Paypal