Macros in Fargo 2

Here are some examples of what programmers can do with macros in Fargo 2.

Anything that appears inside <% and %> is considered a macro, and it runs when the page is rendered. The result of running the macro appears in the rendered page.

Macros are written in JavaScript.

The stuff inside the brackets is just a JavaScript expression, that can call any number of builtin verbs, any standard JavaScript functions, or make HTTP requests using the http.readUrl verb.

If you enter <%2 * 12%> you'll get 24 in the page.

Fargo has an array called snarkySlogans that can be useful for testing this feature.

<%snarkySlogans [5]%> gets you the sixth item in the array, or "You should never argue with a crazy man."

And here's a cute macro that lists all the snarky slogans:

<%s="<ol>"; for (var i=0; i < snarkySlogans.length; i++){s += "<li>" + snarkySlogans [i] + "</li>"}; s + "</ol>"%>

  1. Good for the environment.
  2. All baking done on premises.
  3. Still diggin!
  4. It's even worse than it appears.
  5. Ask not what the Internet can do for you...
  6. You should never argue with a crazy man.
  7. Welcome back my friends to the show that never ends.
  8. Greetings, citizen of Planet Earth. We are your overlords. :blush:
  9. We don't need no stinkin rock stars.
  10. This aggression will not stand.
  11. Pay no attention to the man behind the curtain.
  12. Only steal from the best.
  13. Reallll soooon now...
  14. What a long strange trip it's been.
  15. Ask not what the Internet can do for you.
  16. When in doubt, blog.
  17. Shut up and eat your vegetables.
  18. Don't slam the door on the way out.
  19. Yeah well, that's just, you know, like, your opinion, man.
  20. So, it has come to this.

Also: You can define your own macros, with parameters. (This is not a snarky slogan.)

Last built: Mon, Oct 13, 2014 at 6:48 AM

By Dave Winer, Friday, February 21, 2014 at 12:02 PM. What a long strange trip it's been.