How to opt out from Dataview interpreting and rendeing time-like text in a special way? #508
-
I have such field in a frontmatter: drawing_time: "2.5h" (I started without double quotes, but added them to make sure that value is of a string type) My dataviewjs code passes As output I get How can I achieve that? How can I opt out of automatic value meaning recognition? Extra question: are there any plans for dataviewjs blocks to notrecognize value types by default and, instead, provide me with helper functions so I can do it on my own, under control? Something like: // produces table with text values as they are provided
dv.table(
["date", "duration"],
[["2021-09-29", "2.5h"]]
);
// produces table with date and duration rendered in a special way
dv.table(
["date", "duration"],
[[dv.renderAsDate("2021-09-29"), dv.renderAsDuration("2.5h")]],
{
disableFormatDetection: true,
}
); Asking, because it's not the first time when for my needs I have to trick dataview to avoid special render. I think previously I had similar case with some images rendering in a different way depending whether they were passed as-is to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For the first part, it's hard to do in YAML frontmatter since I don't have any syntax control over "this text should not be interpreted." The alternative which I haven't yet implemented is to add a special For the second part, there are a few coercion functions like |
Beta Was this translation helpful? Give feedback.
For the first part, it's hard to do in YAML frontmatter since I don't have any syntax control over "this text should not be interpreted." The alternative which I haven't yet implemented is to add a special
file.fields
which includes both the interpreted and raw value. I believe you can do it via inline fields by explicitly quoting it ([key:: "value"]
).For the second part, there are a few coercion functions like
dv.date()
anddv.fileLink
which will try to convert strings / links / whatnot to dates. I can add these for durations and numbers as well.