formio / formio.js

JavaScript powered Forms with JSON Form Builder

Home Page:https://formio.github.io/formio.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom file component template

tiberiu89 opened this issue · comments

I need to rewrite parts of the original file template. Copied the exact ejs file from bootstrap4 into my project. Same setup, an .ejs file, and index.ts to export it. I require the file using the ejs-loader for webpack with these settings(nextjs app)

config.module.rules.push({
      test: /\.ejs$/,
      use: {
        loader: 'ejs-loader',
        options: {
          esModule: false,
          variable: 'ctx',
          evaluate: /\{%([\s\S]+?)%\}/g,
          interpolate: /\{\{([\s\S]+?)\}\}/g,
          escape: /\{\{\{([\s\S]+?)\}\}\}/g,
        },
      },
    });

and I'm trying to replace the template

formio.Templates.current.file.form = file.form;

By the looks of it the file.form is compiled to a template but there are some properties access in the template that give an undefined error. More exactly, the template has these ctx.columns.name or size etc. check, but the ctx does not even contain a columns property so it. The ejs-loader seems to have created a template with this syntax

__p += '\n  <ul class="list-group list-group-striped">\n    <li class="list-group-item list-group-header hidden-xs hidden-sm">\n      <div class="row">\n        <div class="col-md-' +
((__t = (ctx.columns.name)) == null ? '' : __t) +
'"><strong>'

Could this be a problem with how ejs-loader is compiling files?

EDIT

Tried solving these by settings some default onto the ctx variable. I kinda works, but filesToDelete, filesToUpload functionality does not seem to work anymore

Closing as probably confused where templates are stored. In version 4.17.3, seems they are in the same repo as with the library, I took the template from a different repo.