outaTiME / grunt-replace

Replace text patterns with applause.
MIT License
411 stars 47 forks source link

If inner key-value pair doesn't exist, replace as blank (empty) #55

Closed doshprompt closed 9 years ago

doshprompt commented 10 years ago

currently, it replaces the outer as object and leaves the rest of the string intact (after the dot notation) like so:

FOO - {"title":"FOO"}.description

outaTiME commented 10 years ago

Hi pal, oups ... you can share a full example ?? 

Thks !!!

On Mon, Aug 18, 2014 at 8:20 PM, Rahul Doshi notifications@github.com wrote:

currently, it replaces the outer as object and leaves the rest of the string intact (after the dot notation) like so:

FOO - {"title":"FOO"}.description

Reply to this email directly or view it on GitHub: https://github.com/outaTiME/grunt-replace/issues/55

doshprompt commented 10 years ago

Here is the complete example

https://gist.github.com/doshprompt/17221fb86570cb142ea4

It might be an underlying issue with applause.

outaTiME commented 10 years ago

Sorry for delay pal, im overloaded ...

this is valid escenario cos @@inner exist in the replacement table check out the applause docs:

https://github.com/outaTiME/applause#patternsjson

in the snippet says:

replaces "@@inner" with string representation of "inner" object

it will be useful in some kind of situations propably in others not ... mmmm ... my best effort is to define a configuracion key to ignore the root objects, what do you thing ??

doshprompt commented 10 years ago

Hey np, thanks for getting back to me though.

I looked at the linked section in applause, I think it shouldn't be evaluating in chunks but the thing as a whole first. The snippet makes sense but in this situation I am doing

@@outer.inner

so it should evaluate outer.inner together and not replace outer and then inner separately.

Do you see what I mean? I think the config option is fine but it would be better to have it on by default instead of off, since this seems more natural to me. What do you think?

outaTiME commented 9 years ago

Hi pal, its impossible to detect the full "token", applause replaces the first occurrence on the matching tree ...

the bigger match should be replaced at first if we found "@@inner.hai" in the matching tree it will be resolved before "@@inner" ... im unable to resolve this kind of replacement =(

if you got some idea how to deal with that, PR will be welcome ...

outaTiME commented 9 years ago

no updates, closing for now ...