Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need better support for functions #2475

Open
acampove opened this issue Nov 15, 2024 · 1 comment
Open

Need better support for functions #2475

acampove opened this issue Nov 15, 2024 · 1 comment
Labels
feature-request New feature or request.

Comments

@acampove
Copy link

Is your feature request related to a problem? Please describe.

There are cases when the user needs to implement complex logic in the tasks, e.g. the user needs to take the starting data of a task and the ending date and make them into a duration span, check if the deadline is approaching soon, etc. All this requires writing code. However, despite we can use the DataView plugin to do something like:

function print_duration(location) {
	const page = dv.pages(location).first();

    const val1 = new Date(page.Start);
    const val2 = new Date(page.End);
    const val3 = (val2 - val1) / (1000 * 3600 * 24);
    
    dv.span(`Task B took ${val3}.`);
}

in a dataviewjs block, we can only use that function inside that block. Thus, whenever we want to use that functionality, the whole block needs to be written.

Describe the solution you'd like

There should be a way to define a separate file where utility functions, written by the user can be added. Those functions should be importable from any task and reusable. This seems a lot like writing a plugin, but many users do not want to write a whole new plugin, we just need a few extra functions that we will have the freedom to implement for our particular usecase

Describe alternatives you've considered
I do not see any workaround, but living without this functionality.

Additional context
Add any other context or screenshots about the feature request here.

@acampove acampove added the feature-request New feature or request. label Nov 15, 2024
@jonathan-tyler
Copy link

Have you considered require() or obsidian-custom-js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants