nanoc / features

Collection of feature requests
2 stars 1 forks source link

Accept 'write nil' as routing to nil #14

Closed denisdefreyne closed 6 years ago

denisdefreyne commented 7 years ago

Migrated from #1063:

In a compile rule, interpret write nil the same as routing to nil.

Steps to reproduce

compile '/foo.*' do
    write nil
end

Expected behavior

Item '/foo.*' should be routed to nil, just as if:

route '/foo.*' do
    nil
end

had been specified.

Actual behavior

Item '/foo.*' is unexpectedly routed by some other routing rule (typically, the catchall route '/**/*', thus to /foo/index.html).

Details

Given that simple routing rules can be expressed more concisely via write inside a compile rule, and that:

compile '/foo.*' do
end

route '/foo.*' do
    '/foo/index.html'
end

can be transformed into:

compile '/foo.*' do
    write '/foo/index.html'
end

one would intuitively expect that:

compile '/foo.*' do
end

route '/foo.*' do
    nil
end

can likewise be transformed to:

compile '/foo.*' do
    write nil
end

but this does not work as expected.