How to insert database values into the template stylesheet?


Tags: jquery,python,css,sqlalchemy,pyramid

Problem :

I have a pyramid app where I insert an entry in my database table on a Zope page template. The chameleon template engine renders it to html. What I want to do is move this entry over by the value column in the database associated with the entry. Here is what I would want to do.

<html>
<p class="entries">${entry.name}</p>
</html>

<style type="text/css">
.entries {
    margin-left: var(entry.value) px;
}
</style>

obviously this is incorrect. Is there a way to do this with JQuery custom css classes perhaps? I don't know how to integrate it with the pyramid framework or the sqlalchemy ORM.



Solution :

Looks like it is exactly the same in the style sheet as it would be in the rest of the template. You just need to use ${} format. I am not sure what you would do if you wanted to put the css in a separate file though.


    CSS Howto..

    How to differentiate the common css class by using other css class

    css how to only make bold fonts for first
      set

    How to use CSS for formatting Crystal Report in Winform?

    How can I render country flags as a ribbon, using CSS only?

    How can i enlarge wesite font-size when used with vw unit for WCAG (accessibility) propeses?

    How to stop all CSS overrides on a container DIV?

    How to keep sub div from considering height of its cousin?

    How to indent text exactly one character width

    What's the difference between “.” and “#” in CSS and how to choose to use?

    how to display labels inline with inputs, using w3.css

    Slideshow won't accept fixed height

    How to make background image with aspect ratio in html and css [closed]

    How do I align an image within a pan/hover border/box?

    How to read CSS property of Psuedo class in javascript

    How to highlight the difference of two texts with css? [closed]

    How do we add the spot bulging effect in css? [closed]

    how to use javascript to get visited link css styles

    Yahoo news CSS, how to achieve behavior

    How to make a basic event calendar with javascript, jquery, html and css?

    How to add static files using Spring MVC and Thymeleaf

    CSS in CKEDITOR - How to make a HTML code like

    display in red color?

    How to detect if browser support specified css pseudo-class?

    How can I show hidden element when it has focus?

    How to use css selector with “not” in c#?

    How can I add some css to center certain divs if they are using the same css style? [duplicate]

    How can I fix my CSS/HTML that uses input:checked, to prevent radio button movement?

    How to force two elements become hovered at the same time?

    How do I achieve this particular hover effect?

    How to reposition CSS-hover popups to stay within a fixed frame?

    How to access two Ids in one css selector