4

I'm trying to parse markdown files stored on the server, and display them inside EE templates in a nice automatic fashion.

My first idea was to read the files using Stash, then parse them using Smartdown. However, I have run into a problem:

Stash assumes the files have an extension of .html. If I use this:

{exp:stash:get name="index.md" file="yes"}

I get the error:

Stash: the file "/path/to/stash/index.md.html" was not found.

Is there a way to tell Stash not to automatically add the .html extension?

Alternatively, is there another easy way to read in files (and cache them)?

  • Which version of stash are you using? Looks like the file param will be depreciated FWIW: github.com/croxton/Stash/tree/dev#file--yesno I guess I wonder if you'd get the same error with {stash:embed} or not and the most recent beta. – Natetronn Dec 6 '12 at 2:07
  • 1
    I'm kind of thinking this will turn into a feature request :) – Natetronn Dec 6 '12 at 2:12
5

Sounds like a great idea to me. I've added it to the issue list:

https://github.com/croxton/Stash/issues/31

| improve this answer | |
2

Stash currently only supports templates with a .html extension (mod.stash.php):

$file_path = $this->path . implode('/', $file_path) . '.html';

[This answer originally included an untested Stash code tweak which I've removed as Mark's confirmed that it won't work.]

| improve this answer | |
  • 2
    I don't think this will work, Stash runs the filename through the url_title() helper function and that will strip out the period . The reason it works this way currently is I didn't want to allow the possibility for local file inclusion type attacks, should anyone be foolish enough to use a dynamic/user-submitted value for a file name. – Mark Croxton Dec 6 '12 at 19:00
  • Thanks for the clarification Mark. I only had a cursory look at the code, so it was a bit of a shot in the dark. I've removed the suggested code changes from my post. – Dom Stubbs Dec 6 '12 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.