Closed waltercoots closed 9 years ago
That's a great explanation! It may seem really strange but as far as I understand, what you are describing is the intended behaviour. Let me explain:
The reason this is happening is because Sketch Data Populator stores the original string in the text layer, e.g. "Pencils, {var1}, and pens" to the layer's metadata when you populate it. This is in order to be able to re-populate the text layer with new data. If it didn't store it in the metadata, the original string with the placeholders would be lost in the process of populating, hence it wouldn't be possible to re-populate the layer.
If you wish to change the original string, e.g. "Pencils, {var1}, and pens" to "!!! Pencils! {var1}, and pens!!!", you need to select the layer(s) and run the 'Restore Placeholders' command which is located next to the other Sketch Data Populator commands. This will put the original strings back and clear the metadata. At this point, you can edit the string and when you next populate, the changes should be taken into account.
I hope that helps. If you have any questions, don't hesitate to ask.
hey @waltercoots, did @lukas77me explanation help you?
It did, thanks! And sorry for the belated reply. I suppose it's ultimately a question of whether or not the average user would expect the metadata / original placeholders to be removed once they edited the text manually. That's sort-of what I was anticipating. But now that I have a grasp on how it works, I've been using it with no problems. And the ability to restore the placeholders is so great!
It may be tricky to explain what's happening, but I'll try:
I created a JSON file from scratch, and ran it through jsonlint.com to validate it. I created the element in Sketch I wanted to populate, and ran the data file through Sketch Data Populator. The first time, it operated fine. But after some tweaking, I wanted to change some of the data - (specifically, shorten the names of some of the properties so I didn't have to have wide text boxes to accommodate them).
The new variable names weren't going through, however, and in fact I discovered that the entire value of the field was being overwritten with what had previously been put in by Sketch Data Populator. So for example, if the field was "Pencils, {var1}, and pens", and I changed it to, "!!! Pencils! {var1}, and pens!!!", Sketch Data Populator would parse the data with no apparent errors, but the field would read, "Pencils, crayons, and pens" instead of "!!! Pencils! crayons, and pens!!!"
I tried quitting Sketch and reopening it, and even uninstalling Sketch Data Populator and reinstalling, but nothing worked. But finally, I was able to circumvent the problem by creating entirely new objects instead of simply duplicating the old ones. This seemed to be a serviceable workaround.
Unfortunately I can't share the files since I'm under an NDA. I'd been working in the file for some time, and without knowing more about how the plug-in works, I can't offer much help on how to replicate, especially since I don't remember what all I did or how it happened.