Issue #1372Opened August 21, 2018by mm5804860 reactions

change block on export

Question

i want change my view but not on export

for sample i added this code


blockManager.add('products', {
  label: 'products',
  content: '
  <ul>
    {% for product in products %}
      <li>{{ product.name }}</li>
    {% endfor %}
  </ul>
',
});

and now i want show this code on view


blockManager.add('products', {
  label: 'products',
  content: '
  <ul>
      <li>car</li> <!-- fake data for show on view -->
      <li>train</li> <!-- fake data for show on view -->
  </ul>
',
});

how can i take this action ?

Answers (2)

artfAugust 24, 20180 reactions

I'd make a custom component to handle such a case.

domc.addType('data-list', {
	model: ...
		defaults: () => ({
			...
			list: []
		}),

	view: ...
		render() {
			... 
			const list = this.model.get('list');
			const content = this.el.innerHTML;
			// interpolate / use some template engine
		}
});

blockManager.add('products', {
  label: 'products',
  content: `
  <ul gjs-data-type="data-list" gjs-data-list="[{...}, {...}]">
    {% for product in products %}
      <li>{{ product.name }}</li>
    {% endfor %}
  </ul>
`,
});
lock[bot]September 17, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.