middleman / middleman

Hand-crafted frontend development
https://middlemanapp.com
MIT License
7.05k stars 748 forks source link

URL Params #1532

Closed fgarcia closed 9 years ago

fgarcia commented 9 years ago

I have seen that in v4 the request helper method was removed

What are the alternatives to access the url params while rendering a template?

tdreyno commented 9 years ago

Well, static websites don't have a means of reading the url, outside of Javascript. I'd caution against it, as it would only work in dev mode and hosting a dev mode site isn't going to be very fast. What is your use case?

fgarcia commented 9 years ago

Although I also just dump static content, most of my pages render extra sections with notes, ideas and some info ala rails footnotes... that are only visible in development.

Mostly I just wanted an easy way to switch between the development and production rendering by adding en environment variable

tdreyno commented 9 years ago

Ah, cool. let me think on this

fgarcia commented 9 years ago

I find convenient having production? and development? helpers globally which are affected by some url param like env=production

However since I use dnsmasq for custom dev domains, I am starting to think that it would be even more convenient using a prod/dev subdomain. That way I could easily switch the middleman server environment in a way that persists after clicking on links.

fgarcia commented 9 years ago

@tdreyno I will not change the topic of this issue, but I have been exploring using subdomains instead url params. This is my ideal setup to access middleman:

mysite.dev (defaults to development mode) production.mysite.dev development.mysite.dev build.mysite.dev

Is there any easy hack to access the domain so I can build my env helpers around them?

tdreyno commented 9 years ago

@fgarcia That's the primary question. Should we expose our web server environment to Middleman, like we did in v3. I think you've convinced me, but I need to think about the API

fgarcia commented 9 years ago

if missuse is an issue, what about exposing it only to extensions?

That way people will think twice about the reasons of not being exposed in the normal environment along other helpers.

tdreyno commented 9 years ago

Ok, added as:

rack[:request]

In template/helper context.