Bug introduced in V10.0 and persisting through V10.4

Since V10.3 the bug still remains but additionally the Genarate and GenerateDocument examples, previously working correctly, are now exhibiting a new described in: What has changed in the Template system in 10.3?

The problem

GenerateDocument[ _NotebookObject ] seems to do the same what TemplateApply[ NotebookTemplate @ _NotebookObject ] does except that the latter evaluates more than it should. It does not respect "leave unevaluated" cell properties.


Let's create a File -> New -> Template Notebook and fill it with the following template:

TemplateExpression[ "test: " <> TemplateSlot["tag", DefaultValue -> "DEFAULT"]]

enter image description here

created using available DockedCells' buttons Slot/Expression. The Cell Behaviour is set to Leave Unevaluated.

Generate test gives me anticipated:

enter image description here

the same result I get with

 Notebooks[][[2]]  (*this template was 2nd on my Notebooks[] list*)


 NotebookTemplate @ Notebooks[][[2]]

Gives correct notebook but evaluates the cell printing

"test: DEFAULT"

The same is the case when I add parameters like <|"tag" -> "test2134"|> to those functions.


Behaviour of TemplateApply is unexpected to me.

Why this evaluation happens? Have I missed something in documentation?

I don't see any reason why that cell is evaluated. And I don't see how my opinion may change with small update of docs like suggested by support:

I have not heard back from the developers for the question yet. It looks like that




returns different results, and yet in the documentation this is not mentioned.

I have filed a suggestion for adding the clarification of this issue. Thank you very much for giving us feedback and hopefully this issue would be improved in future release.'

That's why I'm adding .


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.