Vimscript, 116 115 bytes
Pretty messy but it works!
fu A(n)
let @z="Vkyjply4lpjy4hp"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu
To call it: call A(3)
in an empty buffer. To load the function, source cake.vim
Explanation
2i+<Esc>5i-<Esc>
writes the first line+-----+
o||<Esc>5i<Space><Esc>
adds| |
on the second lineVkyjply4lpjy4hp
is saved in the macro@z
- it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.#@z
repeats this#
timesddl4x
deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layerggd$i_|_|_
replaces the first line by the top of the cake%ce
then centers the whole cake to the width of the bottom layer! !