Closed tupton closed 10 years ago
slice
works on the array of matched values if there is more than one, not on the resulting string of code (eg. {{ .els | slice .... }}
. I see that this is confusing, maybe the name of slice should be changed.
You can't access primitive values, just other nodes, so you can't get the string's value as that is a primitive value. Maybe you should be able to do this, but we would need to do something to make it work.
Currently there is no way to modify the outputted string of code. In Grasp 0.3.0 I will add a replace
filter which you can use to make any regex replacement on the outputted string of code and do what you want.
Also, if you want to do filters on the object itself, you can do {{:root | filter ...}}
- maybe we should make this implicit if you simply do {{ | filter }}
.
Also, if you want to do filters on the object itself, you can do
{{:root | filter ...}}
That's something I was certainly looking for. It was not obvious how to do that; the str
workaround seemed a little unnecessary.
Currently there is no way to modify the outputted string of code. In Grasp 0.3.0 I will add a
replace
filter which you can use to make any regex replacement on the outputted string of code and do what you want.
That would be great for this case, and I'm sure many others. What's the status of this? Is there an in-progress version of replace
? What's the eta for Grasp 0.3.0?
@tupton
I want to release LiveScript 1.3 before Grasp 3.0, but I've just added the replace
filter functionality to the repo (along with uppercase
, lowercase
, trim
, substring
, and substr
filters). You can clone the repo and install it to get the latest functionality before I make a release.
Awesome, thanks for the quick response. This (replace
) does exactly what I need.
Note that filter arguments are now required to be separated by commas.
I'm going to reopen this as we still have several unresolved issues:
:root
when referencing the element itselfAdded str-slice
filter to slice string output with https://github.com/gkz/grasp/commit/4bcd69825f6243c5397bb2ef6d1eeb2ff560188f
Just added implied root selector (see referenced commit above).
Will close this issue and create new ones for any remaining tasks.
I'm trying to replace all strings so that they have a consistent quote style.
Things I've tried:
And probably some more. I cannot figure this out. How can I match and filter a string's value? What's the best way to do this?