-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: creating a file conditionally #751
Comments
Yup, you can check out the plugin brick as an example. The same conditional syntax within a file also works in file/directory paths. |
I guess I need a bit more formal description of how that works. It looks to me like the mustache is started in the directory above, and continues to the file below. How is that even parsed? Is it like the recursive listing of the brick folder is treated as one flat file, and any newlines embedded within a resulting mustacche are equivalent to newlines in a mustache in a flat file, and only the output newlines delimit actual files to be built? That's about the only theory I can come up with, but did I get it? Also, what is |
Aha... I stared long and hard at the plugin example, and seem to have figured it out through trial and error. The / for a subdirectory ends up literally in the middle of a mustache as a forward slash, which needs to be the beginning of an end-tag. Weird, but I worked it out and got my code working. |
I did it! First brick! https://brickhub.dev/bricks/codepad/0.4.0 |
That's awesome congrats! I'll make sure to work on doc improvements to address the areas you called out 👍 |
Yeah, if you could write a comprehensive guide, or at least a cookbook, on how to use mustache in filenames to (a) provide part of the name, (b) provide all of the basename, (c) provide the name of a directory, and then (d) how to conditionally generate a file, that'd be great. The first three are covered pretty well. The last one was the crazy part. Along with whatever |
@RandalSchwartz I was also confused with the syntax for conditional files. But I just found out that you can use a backslash instead of a slash! If you're on MacOS, that keeps it a single file (not sure about Windows). It is also displayed as a single file when browsing your repo on Github. |
Whoa?! Really!? ok... I gotta go test that out. A backslash is weird to have in a pathname because it'll freak out some tools, but well-written tools should be ok. |
Wow... works great. New brick published! |
https://docs.brickhub.dev/brick-syntax has been updated to address the above topics 🎉 |
Is there a way to conditionally generate a file based on a bool var? I don't mean just generating an empty file, but not even having the file. It's not clear to me how mustache fully works with filenames either, because I see some weird examples in items like bricks/plugin that start a mustache in the directory name and end it at the filename. Is that official?
The text was updated successfully, but these errors were encountered: