Comments (7)
This is an interesting philosophical question. There are two reasons why I might be getting nil
:
- Intentionally, the page shouldn't exist
- Unintentionally, I've made a mistake
The way Stasis works right now is not good in either case. For case 1) it breaks. For case 2) it gives bad error messages.
The backwards compatible fix would be creating good error messages. The breaking change would give us a more lenient API that's nice to use for case 1), but could result in some serious outage issues in case 2). Consider a rogue (some->
taking down the entire site.
Is there some way we could handle both cases without breaking the API? Maybe add an optional options parameter to these functions, making "nil punning" an opt-in feature?
from stasis.
My first thought when reading this was your last suggestion @magnars: Add an optional map with a parameter that specifies whether nils are expected or not when exporting. So 👍 from me!
from stasis.
@magnars @cjohansen Thanks for considering this! An optional options map would be great. I'll try adding that to the codebase. I should probably have it done in the next few weeks :)
from stasis.
I started working on this and I need some feedback. I'm using :ignore-nil-pages?
as an option name. I feel like there are two ways to go about this:
- Include
:ignore-nil-pages?
in the current optional map that is used as the context.
Pros: No added arguments toexport-pages
andserve-pages
Cons: Possibly breaking change to someone already using that keyword, option is passed into the page functions and ring request maps with no clear benefit, just clutter. - Add another optional map just for Stasis options so the new functions will be like this:
serve-pages [get-pages & [options new-options]]
Pros: Surely won't break anyone, doesn't clutter context map and ring request maps
Cons: Now there are two maps calledoptions
in the code.
I feel like option 2 is better because it 100% won't break any existing code, but there is a naming problem. Currently the first optional map is called options
everywhere in the code, and I think if we're going to add another options map we should rename the former to context
or config
. context
fits great with the code examples where the page functions accept an argument called cxt
. Any thoughts?
from stasis.
What do you think of 1) with a namespaced key? :stasis/ignore-nil-pages?
from stasis.
@magnars I like that!
from stasis.
Ok the PR is ready for review 🤠
from stasis.
Related Issues (14)
- Exports should use relative URLs HOT 6
- Statis not in clojar.org HOT 5
- slurp-directory not working for me HOT 9
- which file i should put the following content into? HOT 1
- Leiningen reports warnings with the 'lein deps :tree' command HOT 1
- Avoiding re-export of stale posts HOT 1
- using figwheel HOT 1
- Link to atlanis.net/blog out of date HOT 2
- Can't serve github pages CNAME file HOT 3
- Hot code reloading HOT 5
- slurp-resources fails because of chop-path HOT 13
- Serving pages lazily HOT 1
- README Atom feed example doesn't work with latest `clojure.data.xml`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stasis.