#### [[Obsidian Plugin Templater]] --- # Temporal - Todays Date `<%tp.date.now("YYYY-MM-DD")%>` - Todays Date Offset `<%tp.date.now("YYYY-MM-DD", -1)%>` - Todays Date Custom Week `<%tp.date.now("YYYY-[W]ww", 7)%>` - Todays Date Custom Month `<%tp.date.now("YYYY-[M]MM", 28)%>` - Todays Date Custom Year # Cursors `<%tp.file.cursor(1)%>` this one immediately gets replaced by cursor if the number is 1 additional ones denoted by number order you must "Tab" through with the templater keybinding which i have mapped to `⌥+Tab` `<%tp.file.cursor(2)%>` # Prompts `<%tp.system.prompt("What is my name", "BRYAN")%>` # Logic / Control Flow Basically JavaScript Functions: ```javascript if (tp.file.tags.contains("#todo")) { "This is a todo file !" } else { "This is a finished file !" } ``` ``` <%* if (tp.file.tags.contains("#todo")) { %> This is a todo file ! <%* } else { %> This is a finished file ! <%* } %> ``` can also use `else if` ``` <%* if (1==2) { %> if result <%* } else if (1==1) { %> else if result <%* } else { %> else result <%* } %> ``` Can also use arbitrary [[javascript]]: ``` <%* if (tp.file.title.charAt(0) == "{") { %> <%tp.file.cursor(1)%><%tp.file.include("Templates/Inputs/Book")%> <%* } else if (tp.file.title.charAt(0) == "=") { %> <%tp.file.cursor(1)%><%tp.file.include("Templates/Inputs/Thought")%> <%* } else { %> <%tp.file.cursor(1)%><%tp.file.include("Templates/Inputs/New")%> <%* } %> ``` in here the result of the `tp` api is getting the file name to the `tp.file` object that has a property `.title` so we're getting the first character of that title with pure Javascript through: `.charAt(0)` putting it all together: `tp.file.title.charAt(0)` # Resources https://silentvoid13.github.io/Templater/ --- Tags: Reference: Related: -