Coder Social home page Coder Social logo

Views about goravel HOT 5 CLOSED

goravel avatar goravel commented on July 18, 2024
Views

from goravel.

Comments (5)

hwbrzzl avatar hwbrzzl commented on July 18, 2024 1

Maybe you can follow below:

buf := new(bytes.Buffer)

_, err := buf.ReadFrom(w)
if err != nil {
    return nil, err
}

b := buf.Bytes()

ctx.Response().Data(http.StatusOK, "text/html; charset=utf-8", buf)

from goravel.

hwbrzzl avatar hwbrzzl commented on July 18, 2024

Hi, we advocate front-end separation, there is no plan to support rendering pages for the time being. If you just want to return a simple HTML code, you can use like below:

ctx.Response().Data(http.StatusOK, "text/html; charset=utf-8", []byte("<b>Goravel</b>"))

from goravel.

aeq-dev avatar aeq-dev commented on July 18, 2024

Thanks for reply and sorry for the delay
Please how could I use html file parsing, something like this :

t, _ := template.ParseFiles("views/layout.html", "views/home/index.html")
 err := t.Execute(w, nil)

Thanks

from goravel.

aeq-dev avatar aeq-dev commented on July 18, 2024

Thanks :)

from goravel.

lijialong1313 avatar lijialong1313 commented on July 18, 2024

Thanks for reply and sorry for the delay Please how could I use html file parsing, something like this :

t, _ := template.ParseFiles("views/layout.html", "views/home/index.html")
 err := t.Execute(w, nil)

Thanks

now you can do like this:

type Content map[string]interface{}

func (r *TestController) Test(ctx http.Context) {
	t, _ := template.ParseFiles("views/test.html")
	content := Content{"name": "test"}
	_ = t.Execute(ctx.Response().Writer(), content)
}

from goravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.