Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert JSX to string in template #207

Open
rationalthinker1 opened this issue Jan 26, 2022 · 0 comments
Open

Convert JSX to string in template #207

rationalthinker1 opened this issue Jan 26, 2022 · 0 comments

Comments

@rationalthinker1
Copy link

I have a table generator like so:

data.fields = [
        {
          title: 'ID',
          field: (row) => (<router-link to="/sales/lead/${row.lead_id}">${row.lead_id}</router-link>),
          sort: 'lead.id',
        },
        {
          title: 'Lead Source',
          field: (row) => {
            return `
                <div class="flex-basis-100">
                    <span class="font-semibold">${trimEllip(row.lead_source)}</span>
                </div>
                <div class="flex-basis-100 grow flex items-center justify-end lg:justify-start">
                  <span class="font-light">${trimEllip(row.lead_type)}</span>
                </div>
            `;
          },
          sort: 'lead.lead_source',
          show: Tenant.get('settings.lead.index.show_lead_source_column', true),
        },

the name field would contain whatever it needs to put inside td in a table. How would I write a program to take the jsx and convert it to html string like the field for Lead Source? Also, template string doesn't work inside JSX, any solutions?

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

No branches or pull requests

1 participant