-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
"if data" checks in FileModel #454
Conversation
Signed-off-by: Richard Antecki <richard@antecki.id.au>
Agreed, it is quite silly at the moment, as the original code was not intended for this - this use case came later. However, it is a use case of clear value and is now our current focus. We want to make the whole process of document injection as easy and straightforward as possible. I'm a bit ill right now, but keen to have a chat with you when I get better (hopefully next week) on how we can go about making this change occur in the DocPad core. Thanks. |
No worries. Feel free to drop me a line when you're feeling better. |
Feeling better now, and keen to resolve this. Thanks for your patience :) Can you give me access to the project that requires this functionality? |
Hey mate, welcome back to the world. The project was https://github.com/rantecki/docpad-plugin-tagging I've added you as a collaborator (I assume this is what you meant? I'm a It all works fairly well now though as I spent a fair bit of time Note also that I've used data: " " to get around the empty document issue. Cheers, Richard On Wed, Apr 3, 2013 at 2:03 AM, Benjamin Arthur Lupton <
|
Pulled and released to v6.30.2 :) |
- v6.30.2 April 7, 2013 - Allow for empty `data` when injecting files into the database - Thanks to [Richard A](https://github.com/rantecki) for [pull request #454](#454) - Fixed "No Skeleton" option not working (bug introduced in v6.30.0) - Thanks to [Adrian Olaru](https://github.com/adrianolaru) for [pull request #475](#475)
"if data" checks in FileModel
- v6.30.2 April 7, 2013 - Allow for empty `data` when injecting files into the database - Thanks to [Richard A](https://github.com/rantecki) for [pull request #454](#454) - Fixed "No Skeleton" option not working (bug introduced in v6.30.0) - Thanks to [Adrian Olaru](https://github.com/adrianolaru) for [pull request #475](#475)
I have a need for the dynamic creation of 'virtual' documents (that don't correspond to a physical source file). This, thankfully, appears to be supported by the FileModel class, with the document body being set via the 'data' parameter.
However, as a slight twist, my documents also have empty content (i.e. { data: "" }) as they are only used to pass metadata to the layout, which does all the rendering.
This brings me to my problem: I'm not sure if this is by design, but the two "if data" checks in the FileModel class will evaluate to false for an empty string. This results in @buffer remaining as null, which then results in strange behaviour in the parse() function, and the documents refuse to render/cooperate.
This is all fixed if I change the checks to "if data?" instead. I'm not sure if there was a good reason for them not to be this way?
I could of course pass some dummy value as the document content, e.g. { data: "test" } and then just not render the @content in the layout, but it seems a bit silly, no?