Last active
April 6, 2018 17:07
-
-
Save josephxbrick/be419db08417755d25aac83f0dca296d to your computer and use it in GitHub Desktop.
Using Symbols component to take a "card" in Design mode, turn that into a class definition (using Symbols), and fill instances with json data
This file contains 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
# in design mode there is a Frame called "template" (targeted for code). In template there is a text layer | |
# called "title" (not targeted for code) and a layer called "thumbnail" (also not targeted). You can see how | |
# much using Symbols simplifies the code, and to change the layout, you just change it in design. | |
{Symbol} = require "symbols/Symbol" | |
Template = Symbol template # create Template class out of the frame "template" defined in Design | |
# Handles the JSON | |
getData = "https://api.rss2json.com/v1/api.json?rss_url=http%3A%2F%2Furbansharp.com%2Frss%2F" | |
data = JSON.parse Utils.domLoadDataSync getData | |
articleItems = data.items | |
top = 0 | |
for article in articleItems | |
t = new Template # make class instance | |
y: top | |
t.title.text = article.title | |
t.thumbnail.image = article.thumbnail | |
top += t.height | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment