facebookarchive / exerslide

A framework to create React-based HTML presentations and tutorials.
https://facebookincubator.github.io/exerslide/
Other
437 stars 46 forks source link

Ability to write assertions in separate JS file #17

Closed BlakeTurner closed 7 years ago

BlakeTurner commented 7 years ago

First off: this is a really interesting project. Great work!

Re: the JavaScriptExercise layout

I'm wondering if it would be possible for the slide to include an external JS file instead of requiring that assertions be written in the front matter. Maybe a specific path/naming convention would make this easier to achieve?

The use-case is that we'd like to be able to write the assertions and also optionally fire off analytics events on success/fail. That way we can track the success of any given lesson.

Thanks!

fkling commented 7 years ago

Hey Blake! I'm glad you like exerslide 😃

One thing you can do is use the atRequireExpansion transform in webpack.config.js (example) and in the slide do

---
layout_data:
  assertion: @require('!!raw!path/to/file/')
---

That should include the content of path/to/file/ as a string (I believe I have done this before, but you should try and see whether it really works), just as if you had written the content of the file in the slide.

Is that what you are looking for?

BlakeTurner commented 7 years ago

That is awesome. Thanks!

fkling commented 7 years ago

I assume this resolved then?