Comments (5)
Yeah, a -f
would be handy.
from gomplate.
Something that might be a bit simpler to implement, and would probably flow better with the rest of the built-in functions is:
Hello {{ (jsonfile "data.json").name.first }}
$ gomplate -d data.json < in.txt
Hello Joe!
from gomplate.
...although if I'm taking a path or filename as the argument to jsonfile
, then I don't need to pass it on the commandline...
Conversely, forcing a file to be named a specific way may not be a good plan either. Maybe something like:
Hello {{ (jsonfile "data").name.first }}
$ gomplate -d data.json < in.txt
Hello Joe!
Where "data"
is resolved because the file is named data.json
. I could support mappings with =
like:
$ gomplate -d data=myotherfilename.json < in.txt
Hello Joe!
It'd be interesting to also support other data sources from URLs, so to treat the -d
argument like: alias=URL
, or:
$ gomplate -d data=https://some.url/where/i/can/find/data.json < in.txt
Hello Joe!
This implies a few things:
jsonfile
is a bad name - it should be something more generic likedatasource
- in the absence of
=
, the argument is assumed to be a file in the cwd, and the alias is set to the file name (sans extension) - paths (i.e. anything with a directory name in it, not just the filename) and URLs would require the alias
from gomplate.
I like the "data source alias" idea. Perhaps always use uri style? Like file:// https://?
from gomplate.
yeah - well data.json
is technically a valid relative URL, so if we always use the cwd as the base file:// url, there shouldn't be any special-casing needed.
I was also thinking I could support lots of different formats this way (eventually!) like yaml or toml or even XML, detecting by Content-Type with a fallback to file extension...
from gomplate.
Related Issues (20)
- Allow empty values returned by JSONPath HOT 1
- Processing mixed outputs between custom path & output-dir HOT 1
- Cannot install in GitHub Actions using go install HOT 8
- `file.Write` doesn't respect outputDir HOT 7
- gomplate produces no result and no error HOT 1
- Need to finalize gomplate.Renderer and related types before v4.0.0 HOT 2
- Tests failing on 32-bit builds due to unaligned struct in dependency HOT 5
- Provide TrimLeft and TrimRight Support HOT 8
- Process datasources as templates before the final template
- SQL datasource HOT 3
- bug: can't retrieve from Vault KVv2 mounts with slashes in the name HOT 6
- Release `aarch64` artifact HOT 1
- vault aws iam auth support/documentation
- aws sm and smp datasources fail on EC2 instance HOT 3
- plugin function is executed within an if block that evaluates to false HOT 5
- Is the second example for `coll.Merge` incorrect?
- OS information... HOT 1
- Secrets Manager Datasource Doesn't Appear to Work HOT 3
- Turn off following symlinks HOT 3
- Handling generic path type with versioning in Vault
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gomplate.