Skip to content

Conversation

mitroofann
Copy link

@mitroofann mitroofann commented Nov 12, 2017

I wanted to prepare compiled functions for exchanging between my applications: one app compiles the 'pug' function (a prepared string of function, when using "compileBody"), the other receives a it and builds the function. ('pug' files of my projects are stored on a server "1", but web-server is a server "2").

server 1:

const funcBody = require('mitroofann-pug').compileBody(
	file,
	{
		basedir               : path.parse(filename).dir,
		filename              : filename,
		debug                 : false,
		compileDebug          : false,
		cache                 : false,
		inlineRuntimeFunctions: true
	}
).body;

Server 2:

const script  = require('vm').createScript(funcBody);
const context = require('vm').createContext({});

script.runInContext(context);

const render = context.template;

@rollingversions
Copy link

rollingversions bot commented May 1, 2020

There is no change log for this pull request yet.

Create a changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant