<FromGitter>
<RespiteSage> Ooh, a working serializer.
<FromGitter>
<Blacksmoke16> :)
alexherbo2 has quit [Ping timeout: 272 seconds]
<FromGitter>
<RespiteSage> I've looked a little bit into templating languages (as I've mentioned before, I'm not a web dev, so I'm unfamiliar with them), but I'm having trouble finding something useful for templating program data files (as opposed to markup). I'm trying to do something similar to `What color is this $animal? This is a $color $animal!` where each `$value` would be replaced randomly from lists. Preferably, I'd like the
<FromGitter>
... templates, the names of the lists, and the contents of the lists to be modifiable by a user (i.e. without having to recompile the program), though there will of course need to be an entry point somewhere (i.e. "this list of templates is what you start with; pick randomly from those"). Is a templating language what I need? ... [https://gitter.im/crystal-lang/crystal?at=5f0b52ef7a4e99049e07d5da]
<FromGitter>
<RespiteSage> (For context, I want to modify Discryb (https://github.com/RespiteSage/discryb) to allow user-created data instead of relying on an outside API.
<FromGitter>
<RespiteSage> ("User" meaning the person running the executable.)
<FromGitter>
<Blacksmoke16> then could just have the value be `options.sample`
<FromGitter>
<RespiteSage> Thanks, I'll try that.
<straight-shoota>
RespiteSage, I don't quite follow, what exactly you're asking for
<straight-shoota>
If you just want to replace `$foo` with the value of `foo` looked up from a hash or similar, you don't really need a template engine for that.
<FromGitter>
<Blacksmoke16> `"#{options.sample}"`
<straight-shoota>
`String#gsub` would be perfectly fine for this
<straight-shoota>
Only if you may need more than that, you would really need a template engine
<FromGitter>
<RespiteSage> What I'm looking for is a way to allow the data (plaintext, editable after compilation) to be something like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ or even to allow multiple levels of substitution. Actually, though, I think I have a good idea of how to implement this. I probably don't need templating, like you say. [https://gitter.im/crystal-lang/crystal?at=5f0b5818c7d15f7d0f8b3d98]
<FromGitter>
<RespiteSage> To be clear, example compliments generated from the above data file could be "Your face is just like a green bottlenose dolphin." or "It's really cool how harrowed you are."
alexherbo2 has joined #crystal-lang
<FromGitter>
<Blacksmoke16> and i assume the possible options are static?
<FromGitter>
<Blacksmoke16> or do you expect for someone to be able to dynamically add their own compliment with a new option array?
<FromGitter>
<asterite> to me it looks like that's the program, not a library. Just load the YAML file into a Hash(String, String), then using gsub with a regex should be enough.
<FromGitter>
<RespiteSage> @Blacksmoke16 The possible options are supposed to be configurable at runtime by the user (i.e. your second option). I think that @straight-shoota and @asterite are right; I was just overthinking it, and I can just load it into a hash.
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
... I want anybody who uses it to have an easy time customizing what kinds of compliments (and eventually insults, observations, etc.) they want.
<FromGitter>
<RespiteSage> The basic problem this is solving is that I meant for this bot to be a silly and positive bot to add to a Discord I'm in, and some of the compliments from the API I'm using (https://complimentr.com/) can be just a bit more focused on certain body parts (for instance) than I want. So I want it configurable for me, but also the whole purpose of having an open-source project is so other people can use it, and