Comments (6)
Thanks for building ain
. Totally love it! I also liked your post on atomic commits.
from ain.
Thanks for those kind words!
from ain.
Hi, thanks for reporting!
There is no current way of escaping # yet. I'll think of what makes more sense - escaping it like \#
everywhere or leaving it within quotes.
In the meantime - since this is JSON - you can get around this particular case by using unicode escaping like so:
{
"email": "[email protected]",
"password": "0x143\u0023",
"user_type": "tenant"
}
from ain.
Hi!
I've thought about this and I'd like to keep things such as quoting and escaping out of the way as much as possible in ain. Quoting is only mandatory in 4 places, whitespace in arguments to executables, backend-options, $EDITOR and template-names when piping. Quoting is needed there, while the rest of the template is plain text.
So for escaping comments, I'm thinking one syntax everywhere including inside quotes is simpler than one syntax outside quotes (the majority of the cases) and yet another syntax inside quotes. More syntaxes to keep in your head. The quotes in your JSON-example are accidental because it's JSON, it's not quotes ain knows or cares about.
So, here's my idea. Things that have meaning to ain are #, ${, $(
and [Headings]
on a new line. All will be escaped with a backtick (`). The backtick is visually non-intrusive and unlikely to occur in elsewhere in the template. Escaping the backtick itself is only necessary if you want a literal backtick immediately followed by one of the four cases that have meaning to ain.
`# <- Escaped comment. Outputted as #
\`# <- Escaped ` immediately followed by a comment
`${ <- Escaped envvar. Outputted as ${
\`${ <- Escaped ` immediately followed by an actual envvar expression
`${ <- Escaped executable. Outputted as $(
\`${ <- Escaped ` immediately followed by an actual executable expression
And for symmetry (although escaping a section (e g \[Headers]
) is already supported and we'll keep that but not mention it):
`[Headers] <- Escaped section if preceded only by whitespace on a line.
\`[Headers] <- Literal ` followed by the literal [Headers] preceded only by whitespace on a line.
The backtick enables escaping only in the cases above, everywhere else it's interpreted verbatim and no escaping of it is needed. E g abc`123 is passed as abc`123 and no \` is needed. Only in the rare cases above.
This way quoting gets out of the way as much as possible. Escaped comments are 97% of what people will use. %3 might need the escaped $(
and ${
and I'll bet no-one will need the escaped backtick followed by a literal comment, envvar or executable expression.
Makes sense?
from ain.
Hi @jonaslu!
Thanks for taking your time to think about this.
Based on your explanation above, I think that approach would work okay.
from ain.
Done in commit 4917c65
from ain.
Related Issues (9)
- Add snapcraft build HOT 1
- Define requests based on existing OpenAPI spec HOT 1
- Response processing? HOT 2
- How you can send parameters in GET requests? HOT 8
- Multiple endpoint in same ain file HOT 4
- stderr is piped to stdout HOT 8
- add support for base section HOT 6
- Executable regex misses nested parentheses HOT 1
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 ain.