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

Templates in included pages not evaluated in some cases #1118

Open
mjf opened this issue Oct 17, 2024 · 0 comments
Open

Templates in included pages not evaluated in some cases #1118

mjf opened this issue Oct 17, 2024 · 0 comments

Comments

@mjf
Copy link

mjf commented Oct 17, 2024

SilverBullet version: 0.9.4

When a page containing some template is included with ![[page]] in another one, the templates are not evaluated in some cases. The following works well:

/page/included

This is a page to be included in another one.
```template
{{1+2}}
```

/page

This is the page that includes the other one.
![[/page/included]]

But I have a table in the included page where I summarize a table column using custom space script sum() function. For some reason, if that page is included into another the summation does not work and results in value 0 in the including page. The included page, if viewed, works as expected.

silverbullet.registerFunction({name: 'sum'}, (key, items) => {
  return items
    .map(i => parseFloat(i[key]))
    .reduce((acc, n) => acc + (isNaN(n) ? 0 : n), 0);
});

/page/included

cost | remark
-----|-------
1    | foo
2    | bar

```template
Total: {{ sum( 'cost', { table where page = @page.name }) }}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant