Skip to content

lempzz/string-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

String template for models

We have table of articles:

id title seo_title created_at
1 Game of Thrones: New Episode 2019-05-13 18:04:43

and we need to show title of Article page with specific template, for example {title}. Published at {date}.

$.ajax({
    url: '/articles/1',
    type: 'patch',
    dataType: 'json',
    data: {
        seo_title: '{title}. Published at {date}'
    },
    success: res => {
        console.log(res.data.seo_title) //Game of Thrones: New Episode. Published at 2019-05-13 18:04:43
    }
});

But if we want edit this Article, we will see original text:

$.ajax({
    url: '/articles/1/edit',
    type: 'get',
    dataType: 'json',
    success: res => {
        console.log(res.data.seo_title) //{title}. Published at {date}
    }
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages