Comments (2)
I assume you don't have only daily notes within periodic
exclusively, and therefore don't want daily-template.md
to be applied to all notes you create within (a subfolder of) periodic
?
If so: You can create a "Meta template" and outsource your pattern matching into javascript code within that meta template file. Then include the appropriate template (daily-template.md
, monthly-template.md
, etc.) based on what the Meta Template matches to.
Simple example that assumes Daily Notes are always named "Daily Note YYYY-MM-DD"
<%*
if (tp.file.title.startsWith("Daily Note")){
tp.file.include("[[daily-template.md]]")
} else {
tp.file.include("[[generic-periodic-template.md]]")
}
%>
You can get creative with how to identify the correct template:
- you could get the note's parent folder and match that folder's name to different date formats using string-matching or regex
- You could make use of javascripts
date
objects and turn folder paths into dates, then select the appropriate template based on that - you could include a fallback that prompts a user input if no condition was matched and lets the user choose what kind of periodic note it is
- ...
Good Luck :)
from templater.
Thank you very much, here I understood, that is, it was possible to specify the default template. And it will all work, true slower, but yes okay:
<%*
const folderPath = tp.file.folder(true);
const yearPattern = /(\d{4})y/;
const quarterPattern = /(\d{4}-Q[1-4])/;
const monthPattern = /(\d{4}-\d{2})/;
const weekPattern = /(\d{4}-W\d{2})/;
const dayPattern = /(\d{4}-\d{2}-\d{2})\.md$/;
const isYear = yearPattern.test(folderPath);
const isQuarter = quarterPattern.test(folderPath);
const isMonth = monthPattern.test(folderPath);
const isWeek = weekPattern.test(folderPath);
const isDay = dayPattern.test(folderPath);
if (isDay) {
tR += await tp.file.include("[[daily-template]]");
} else if (isWeek) {
tR += await tp.file.include("[[weekly-template]]");
} else if (isMonth) {
tR += await tp.file.include("[[monthly-template]]");
} else if (isQuarter) {
tR += await tp.file.include("[[quarterly-template]]");
} else if (isYear) {
tR += await tp.file.include("[[yearly-template]]");
}
%>
from templater.
Related Issues (20)
- Applying Text Color in Obsidian Without Unwanted New Lines HOT 2
- Templater no longer works with console error "Plugin failure: templater-obsidian TypeError: c is not a constructor" HOT 2
- The recent upgrade of this plug-in has broken "Trigger Templater on new file creation" HOT 6
- {{date}} fail to work after updating to 2.3.3 HOT 1
- Target file gets overwritten by processFrontMatter() HOT 1
- Note Creation with Core Plugin "Note Composer" Breaks Templater HOT 1
- Option to add ignored files to Templater settings HOT 2
- Copy existing file with templater HOT 1
- Templater file module does not support the concurrent creation of files HOT 4
- Folder Template overwrites non-empty note HOT 2
- Daily Quote errors HOT 7
- Template folder location should allow subfolders HOT 2
- Obsidian version 1.6.5 installs template. When creating a template, it will prompt that the relevant plug-in is not found. HOT 1
- Support for Folder Templates specific to subfolders
- [Feature Request] Mobile | tp.system.prompt with MULTILINE - Using a Keyboard Hotkey to SUBMIT
- When using tp.file.cursor inside an internal link with a heading, cursor is placed before the link HOT 1
- Embedded image causes Obsidian to lock up for 45 seconds in renderer HOT 1
- Link to a new file will trigger Templater in a specific folder HOT 2
- Feature request: allow for ordering which templater code is excuted first HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templater.