Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

does fmpp command line support stdout mode insteadof create file? #13

Open
leeluolee opened this issue Apr 26, 2015 · 7 comments
Open

Comments

@leeluolee
Copy link

I tried fmpp like

fmpp  test/template/index.ftl   >  index.html

but got following result

Failed!
The "outputRoot" setting was not set. FMPP can't start working without that.

I think , the outputRoot must be a Optional arguments to help developer use stdout in other way . like text processing.

Just a suggestion.

@ddekany
Copy link
Contributor

ddekany commented Apr 26, 2015

Yes, that's on the FMPP TODO actually. (It's not entirely trivial, because FMPP can output to multiple files and such, which doesn't make sense with stdout.)

@leeluolee
Copy link
Author

I use fmpp for rendering a 【freemarker template】 in nodejs application. The idealy way to use fmpp is

shell.run("fmpp some/path/to/index.ftl -D xxx", function(err, compileContent){  // data is the stdout's data stream
   response.send(compileContent)
})

but I found that, before I got the compileContent, I have to 【read from a tmp file】 then 【unlink the tmp file after reading】. (in fmpp process, there is also a useless writing operation)

So, I think , It is not necessary to force people to pass Output to fmpp, just log the result to stdout if people doesn't pass the argument in command-line.

@ddekany
Copy link
Contributor

ddekany commented Apr 26, 2015

How it probably will be, if I ever had time for it, is that you can pass --stdin and/or --stdout to FMPP. This also means that one can combine the two and use FMPP as a filter. Why I don't want these to be the default is simply that the typical usage patterns is file-to-file and directory-to-directory, and if there will be default then FMPP can give less useful error messages when someone forgets to provide the source or the output. The user would just see the screen flooded or FMPP being frozen (actually waiting for stdin)...

@leeluolee
Copy link
Author

--stdin or --stdout is good enough for my needs, thanks . Looking forward to your updating. :)

@katiesandford
Copy link

👍 When will this be released? :)

@ddekany
Copy link
Contributor

ddekany commented Oct 6, 2015

It wasn't even implemented, so I really don't know.

@MulixBF
Copy link

MulixBF commented Jan 7, 2019

Trivial kludge in bash. Maybe someone would be interested

function fmpp_stdin() {
    template_file=$(mktemp)
    output_file=$(mktemp)
    template=$1 && shift

    echo "$template" > "$template_file"
    fmpp -q "$template_file" -o "$output_file" "$@"
    cat "$output_file"
    rm "$template_file"
    rm "$output_file"
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants