s4l1h / assetfile

assetfile
0 stars 0 forks source link

slmlar #1

Open stnc opened 4 years ago

stnc commented 4 years ago

hocam bunun pongo ile örneğini anlamadım ben ya html ve go dosyalı bir örnek yapabilir misin mesela iletişim diye bir modulum var fakat benim sadece buraya ait js ve css dosylarım var onu nasıl eklemem gerek her modul bazında eklenebilir bu modul ile ama ben yapamadım.

s4l1h commented 4 years ago

@stnc malesef istediğin şey ile bu kütüphanenin yaptığı şeyler çok farklı. Pongo örneği şurada var. https://github.com/akmyazilim/assetfile/tree/master/assetfilepongo#example

Bu kütüphane sadece dosya adlarını belirli bir sırada yüklemek ve aynı dosyanın birden fazla eklenmesini önlemek için yazıldı.

stnc commented 4 years ago

yok abi yaptım ben senin modul işime yaradı, sağol modul için başkaları içinde not olarak bırakayım

// main.go (echo fw)

func index(db *gorm.DB) func(echo.Context) error { return func(c echo.Context) error { var total int

    db.Find(&activities).Count(&total)
    postsPerPage := 50
    paginator = pagination.NewPaginator(c.Request(), postsPerPage, total)
    offset := paginator.Offset()

    db.Debug().Limit(postsPerPage).Order("id asc").Find(&activities).Offset(offset).Find(&activities) //old

    css := assetfile.New()
    css.Add("a.css")
    css.Add("b.css")
    css.Add("a.css")
    css.Add("c.css")
    css.Add("b.css")
    css.Add("foo_%s.css", "module")
    css.Add("foo_%s_%d.css", "module", 1)
    /*
        for key, value := range css.List() {
            fmt.Println(value)
            fmt.Println(key)
        }
    */
    data = pongo2.Context{"paginator": paginator, "title": "Kumbara", "posts": activities, "msg": msg, "css": css.List()}
    return c.Render(http.StatusOK, "templates/kumbara/index.html", data)
}

}

// index.html kısmına yazılacak (yada footer.html veya header.html )

{% for cssURL in css %} link href="{{ cssURL }}" rel="stylesheet" {% endfor %}