Created
April 25, 2020 10:20
-
-
Save PavelLaptev/6680abdcae0e6f1a5698f1817a1f09b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function populateByTemplateString(selectedLayers, JSONobj, btnName) { | |
let newItem = 0; | |
const loopSelected = arr => { | |
arr.map(item => { | |
if (item.type === 'TEXT' && item.characters.includes(`{${btnName}}`)) { | |
figma.loadFontAsync(item.fontName).then(() => { | |
item.characters = item.characters.replace(`{${btnName}}`, JSONobj[newItem][btnName].toString()); | |
newItem = ++newItem; | |
}); | |
} | |
if (item.children) { | |
loopSelected(item.children); | |
} | |
}); | |
}; | |
loopSelected(selectedLayers); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment