Search results

There are no results.

wobsite.UpdateAssetLinks

class pub UpdateAssetLinks

A type that updates an HTML document such that asset links (e.g. CSS files) contain a hash, ensuring that updates bust browser caches.

This type doesn't physically rename any files, instead it adds a ?hash=VAL query string to each relevant asset link.

Static methods

new

Show source code
Hide source code
fn pub static new(files: ref Files, url: String) -> UpdateAssetLinks {
  UpdateAssetLinks(files, url)
}
fn pub static new(files: ref Files, url: String) -> UpdateAssetLinks

Returns a new UpdateAssetLinks.

The files argument is the list of site files to use when updating links.

The url argument is the relative URL of the page that's being processed.

Instance methods

run

Show source code
Hide source code
fn pub run(document: mut html.Document) {
  let nodes = document.nodes.iter_mut.to_array

  loop {
    match nodes.pop {
      case Some(Element(el)) -> {
        element(el)
        nodes.append(el.nodes.iter_mut.to_array)
      }
      case Some(_) -> {}
      case _ -> break
    }
  }
}
fn pub run(document: mut Document)

Updates any asset links in the given HTML document.