0

I'm trying to generate triangle-pattern backgrounds server-side (ruby) using trianglify.js and gem 'therubyracer' (also tried execjs - same error)

I use the following code

 require 'v8'
 cxt = V8::Context.new
 cxt.load('trianglify.js')
 png = cxt.eval("var pattern = Trianglify({width: 200, height: 200}); return pattern.png()")
 puts png

Loaded script https://cdnjs.cloudflare.com/ajax/libs/trianglify/1.0.1/trianglify.js

Error

V8::Error: require is not defined
at trianglify.js:8:16
Ilya Cherevkov
  • 1,743
  • 2
  • 17
  • 47

0 Answers0